diff --git a/java-spiffe-core/src/main/java/spiffe/internal/CertificateUtils.java b/java-spiffe-core/src/main/java/spiffe/internal/CertificateUtils.java index 34f2000..1c87f40 100644 --- a/java-spiffe-core/src/main/java/spiffe/internal/CertificateUtils.java +++ b/java-spiffe-core/src/main/java/spiffe/internal/CertificateUtils.java @@ -1,7 +1,6 @@ package spiffe.internal; import lombok.val; -import lombok.var; import spiffe.spiffeid.SpiffeId; import spiffe.spiffeid.TrustDomain; @@ -160,11 +159,11 @@ public class CertificateUtils { // Given a private key in PEM format, encode it as DER private static byte[] toDerFormat(byte[] privateKeyPem) { - var privateKey = new String(privateKeyPem); - privateKey = privateKey.replaceAll("(-+BEGIN PRIVATE KEY-+\\r?\\n|-+END PRIVATE KEY-+\\r?\\n?)", ""); - privateKey = privateKey.replaceAll("\n", ""); + String privateKeyAsString = new String(privateKeyPem); + privateKeyAsString = privateKeyAsString.replaceAll("(-+BEGIN PRIVATE KEY-+\\r?\\n|-+END PRIVATE KEY-+\\r?\\n?)", ""); + privateKeyAsString = privateKeyAsString.replaceAll("\n", ""); val decoder = Base64.getDecoder(); - return decoder.decode(privateKey); + return decoder.decode(privateKeyAsString); } private CertificateUtils() {} diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java index a537ed8..999df0e 100644 --- a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java +++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/BackoffPolicy.java @@ -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 * * @param retriesCount the current number of retries * @return */ - public boolean doNotExceedMaxRetries(int retriesCount) { + public boolean didNotReachMaxRetries(int retriesCount) { return (maxRetries == UNLIMITED_RETRIES || retriesCount < maxRetries); } } diff --git a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java index ba83f79..daa2977 100644 --- a/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java +++ b/java-spiffe-core/src/main/java/spiffe/workloadapi/retry/RetryHandler.java @@ -25,7 +25,7 @@ public class RetryHandler { * Updates the next delay and retries count */ public void scheduleRetry(Runnable runnable) { - if (backoffPolicy.doNotExceedMaxRetries(retryCount)) { + if (backoffPolicy.didNotReachMaxRetries(retryCount)) { executor.schedule(runnable, nextDelay.getSeconds(), TimeUnit.SECONDS); nextDelay = backoffPolicy.nextDelay(nextDelay); retryCount++;