diff --git a/spring-vault-core/src/main/java/org/springframework/vault/authentication/MacAddressUserId.java b/spring-vault-core/src/main/java/org/springframework/vault/authentication/MacAddressUserId.java index 72d77281..84996dc4 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/authentication/MacAddressUserId.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/authentication/MacAddressUserId.java @@ -41,7 +41,7 @@ import org.springframework.util.StringUtils; */ public class MacAddressUserId implements AppIdUserIdMechanism { - private final Log log = LogFactory.getLog(MacAddressUserId.class); + private final Log logger = LogFactory.getLog(MacAddressUserId.class); private final String networkInterfaceHint; @@ -100,7 +100,7 @@ public class MacAddressUserId implements AppIdUserIdMechanism { if (!networkInterface.isPresent()) { if (StringUtils.hasText(this.networkInterfaceHint)) { - this.log.warn(String.format("Did not find a NetworkInterface applying hint %s", + this.logger.warn(String.format("Did not find a NetworkInterface applying hint %s", this.networkInterfaceHint)); } diff --git a/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java b/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java index bf9e1c68..5e7b5a89 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java @@ -83,7 +83,8 @@ import static org.springframework.vault.support.SslConfiguration.KeyConfiguratio */ public class ClientHttpRequestFactoryFactory { - private static final Log logger = LogFactory.getLog(ClientHttpRequestFactoryFactory.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(ClientHttpRequestFactoryFactory.class); private static final boolean HTTP_COMPONENTS_PRESENT = isPresent("org.apache.http.client.HttpClient"); diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/env/LeaseAwareVaultPropertySource.java b/spring-vault-core/src/main/java/org/springframework/vault/core/env/LeaseAwareVaultPropertySource.java index 1fc236e6..475273ff 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/core/env/LeaseAwareVaultPropertySource.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/core/env/LeaseAwareVaultPropertySource.java @@ -56,7 +56,8 @@ import org.springframework.vault.support.JsonMapFlattener; */ public class LeaseAwareVaultPropertySource extends EnumerablePropertySource { - private static final Log logger = LogFactory.getLog(LeaseAwareVaultPropertySource.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(LeaseAwareVaultPropertySource.class); private final SecretLeaseContainer secretLeaseContainer; diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/env/VaultPropertySource.java b/spring-vault-core/src/main/java/org/springframework/vault/core/env/VaultPropertySource.java index 32049942..b68de806 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/core/env/VaultPropertySource.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/core/env/VaultPropertySource.java @@ -47,7 +47,8 @@ import org.springframework.vault.support.VaultResponse; */ public class VaultPropertySource extends EnumerablePropertySource { - private static final Log logger = LogFactory.getLog(VaultPropertySource.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(VaultPropertySource.class); private final String path; diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseContainer.java b/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseContainer.java index 84c4d656..d1222f4b 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseContainer.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseContainer.java @@ -132,7 +132,8 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I private static final int STATUS_DESTROYED = 2; - private static final Log log = LogFactory.getLog(SecretLeaseContainer.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(SecretLeaseContainer.class); private final List requestedSecrets = new CopyOnWriteArrayList<>(); @@ -608,14 +609,14 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I private static void logRenewalCandidate(RequestedSecret requestedSecret, Lease lease, String action) { - if (log.isDebugEnabled()) { + if (logger.isDebugEnabled()) { if (lease.hasLeaseId()) { - log.debug(String.format("Secret %s with Lease %s qualified for %s", requestedSecret.getPath(), + logger.debug(String.format("Secret %s with Lease %s qualified for %s", requestedSecret.getPath(), lease.getLeaseId(), action)); } else { - log.debug(String.format("Secret %s with cache hint is qualified for %s", requestedSecret.getPath(), + logger.debug(String.format("Secret %s with cache hint is qualified for %s", requestedSecret.getPath(), action)); } } @@ -784,7 +785,8 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I */ static class LeaseRenewalScheduler { - private static final Log log = org.apache.commons.logging.LogFactory.getLog(LeaseRenewalScheduler.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(LeaseRenewalScheduler.class); private final TaskScheduler taskScheduler; @@ -812,13 +814,13 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I void scheduleRenewal(RequestedSecret requestedSecret, RenewLease renewLease, Lease lease, Duration minRenewal, Duration expiryThreshold) { - if (log.isDebugEnabled()) { + if (logger.isDebugEnabled()) { if (lease.hasLeaseId()) { - log.debug(String.format("Scheduling renewal for secret %s with lease %s, lease duration %d", + logger.debug(String.format("Scheduling renewal for secret %s with lease %s, lease duration %d", requestedSecret.getPath(), lease.getLeaseId(), lease.getLeaseDuration().getSeconds())); } else { - log.debug(String.format("Scheduling renewal for secret %s, with cache hint duration %d", + logger.debug(String.format("Scheduling renewal for secret %s, with cache hint duration %d", requestedSecret.getPath(), lease.getLeaseDuration().getSeconds())); } } @@ -838,17 +840,17 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I LeaseRenewalScheduler.this.schedules.remove(lease); if (LeaseRenewalScheduler.this.currentLeaseRef.get() != lease) { - log.debug("Current lease has changed. Skipping renewal"); + logger.debug("Current lease has changed. Skipping renewal"); return; } - if (log.isDebugEnabled()) { + if (logger.isDebugEnabled()) { if (lease.hasLeaseId()) { - log.debug(String.format("Renewing lease %s for secret %s", lease.getLeaseId(), + logger.debug(String.format("Renewing lease %s for secret %s", lease.getLeaseId(), requestedSecret.getPath())); } else { - log.debug(String.format("Renewing secret without lease %s", requestedSecret.getPath())); + logger.debug(String.format("Renewing secret without lease %s", requestedSecret.getPath())); } } @@ -860,7 +862,7 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I LeaseRenewalScheduler.this.currentLeaseRef.compareAndSet(lease, renewLease.renewLease(lease)); } catch (Exception e) { - log.error(String.format("Cannot renew lease %s", lease.getLeaseId()), e); + logger.error(String.format("Cannot renew lease %s", lease.getLeaseId()), e); } } }; @@ -876,8 +878,8 @@ public class SecretLeaseContainer extends SecretLeaseEventPublisher implements I ScheduledFuture scheduledFuture = this.schedules.get(lease); if (scheduledFuture != null) { - if (log.isDebugEnabled()) { - log.debug( + if (logger.isDebugEnabled()) { + logger.debug( String.format("Canceling previously registered schedule for lease %s", lease.getLeaseId())); } diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseEventPublisher.java b/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseEventPublisher.java index efe544a5..28beebe8 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseEventPublisher.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/core/lease/SecretLeaseEventPublisher.java @@ -224,11 +224,13 @@ public class SecretLeaseEventPublisher implements InitializingBean { INSTANCE; - private static final Log log = LogFactory.getLog(LoggingErrorListener.class); + @SuppressWarnings("FieldMayBeFinal") // allow setting via reflection. + private static Log logger = LogFactory.getLog(LoggingErrorListener.class); @Override public void onLeaseError(SecretLeaseEvent leaseEvent, Exception exception) { - log.warn(String.format("[%s] %s %s", leaseEvent.getSource(), leaseEvent.getLease(), exception.getMessage()), + logger.warn( + String.format("[%s] %s %s", leaseEvent.getSource(), leaseEvent.getLease(), exception.getMessage()), exception); }