Change method name to improve clarity.

Fix build warning.

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
This commit is contained in:
Max Lambrecht 2020-05-08 07:36:03 -03:00
parent 9867c032cf
commit f8a176dc20
3 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package spiffe.internal; package spiffe.internal;
import lombok.val; import lombok.val;
import lombok.var;
import spiffe.spiffeid.SpiffeId; import spiffe.spiffeid.SpiffeId;
import spiffe.spiffeid.TrustDomain; import spiffe.spiffeid.TrustDomain;
@ -160,11 +159,11 @@ public class CertificateUtils {
// Given a private key in PEM format, encode it as DER // Given a private key in PEM format, encode it as DER
private static byte[] toDerFormat(byte[] privateKeyPem) { private static byte[] toDerFormat(byte[] privateKeyPem) {
var privateKey = new String(privateKeyPem); String privateKeyAsString = new String(privateKeyPem);
privateKey = privateKey.replaceAll("(-+BEGIN PRIVATE KEY-+\\r?\\n|-+END PRIVATE KEY-+\\r?\\n?)", ""); privateKeyAsString = privateKeyAsString.replaceAll("(-+BEGIN PRIVATE KEY-+\\r?\\n|-+END PRIVATE KEY-+\\r?\\n?)", "");
privateKey = privateKey.replaceAll("\n", ""); privateKeyAsString = privateKeyAsString.replaceAll("\n", "");
val decoder = Base64.getDecoder(); val decoder = Base64.getDecoder();
return decoder.decode(privateKey); return decoder.decode(privateKeyAsString);
} }
private CertificateUtils() {} private CertificateUtils() {}

View File

@ -67,13 +67,13 @@ public class BackoffPolicy {
} }
/** /**
* Returns true if the RetryPolicy is configure with UNLIMITED_RETRIES * Returns true if the RetryPolicy is configured with UNLIMITED_RETRIES
* or if the retriesCount param is lower than the maxRetries * or if the retriesCount param is lower than the maxRetries
* *
* @param retriesCount the current number of retries * @param retriesCount the current number of retries
* @return * @return
*/ */
public boolean doNotExceedMaxRetries(int retriesCount) { public boolean didNotReachMaxRetries(int retriesCount) {
return (maxRetries == UNLIMITED_RETRIES || retriesCount < maxRetries); return (maxRetries == UNLIMITED_RETRIES || retriesCount < maxRetries);
} }
} }

View File

@ -25,7 +25,7 @@ public class RetryHandler {
* Updates the next delay and retries count * Updates the next delay and retries count
*/ */
public void scheduleRetry(Runnable runnable) { public void scheduleRetry(Runnable runnable) {
if (backoffPolicy.doNotExceedMaxRetries(retryCount)) { if (backoffPolicy.didNotReachMaxRetries(retryCount)) {
executor.schedule(runnable, nextDelay.getSeconds(), TimeUnit.SECONDS); executor.schedule(runnable, nextDelay.getSeconds(), TimeUnit.SECONDS);
nextDelay = backoffPolicy.nextDelay(nextDelay); nextDelay = backoffPolicy.nextDelay(nextDelay);
retryCount++; retryCount++;