change line wrap and use constants for numbers (#409)
This commit is contained in:
Родитель
2830968745
Коммит
e8fb638a59
|
@ -18,4 +18,7 @@ public class Constants {
|
|||
public static final String AZURE_KEYVAULT_PROPERTYSOURCE_NAME = "azurekv";
|
||||
public static final String AZURE_TOKEN_ACQUIRE_TIMEOUT_IN_SECONDS = "azure.keyvault.token-acquire-timeout-seconds";
|
||||
public static final String AZURE_KEYVAULT_ALLOW_TELEMETRY = "azure.keyvault.allow.telemetry";
|
||||
|
||||
public static final long DEFAULT_REFRESH_INTERVAL_MS = 1800000L;
|
||||
public static final long TOKEN_ACQUIRE_TIMEOUT_SECS = 60L;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,9 @@ class KeyVaultEnvironmentPostProcessorHelper {
|
|||
final String vaultUri = getProperty(this.environment, Constants.AZURE_KEYVAULT_VAULT_URI);
|
||||
final Long refreshInterval = Optional.ofNullable(
|
||||
this.environment.getProperty(Constants.AZURE_KEYVAULT_REFRESH_INTERVAL))
|
||||
.map(Long::valueOf)
|
||||
.orElse(1800000L);
|
||||
.map(Long::valueOf).orElse(Constants.DEFAULT_REFRESH_INTERVAL_MS);
|
||||
final long timeAcquiringTimeoutInSeconds = this.environment.getProperty(
|
||||
Constants.AZURE_TOKEN_ACQUIRE_TIMEOUT_IN_SECONDS, Long.class, 60L);
|
||||
Constants.AZURE_TOKEN_ACQUIRE_TIMEOUT_IN_SECONDS, Long.class, Constants.TOKEN_ACQUIRE_TIMEOUT_SECS);
|
||||
|
||||
final ServiceClientCredentials credentials = new AzureKeyVaultCredential(clientId, clientKey,
|
||||
timeAcquiringTimeoutInSeconds);
|
||||
|
@ -96,7 +95,7 @@ class KeyVaultEnvironmentPostProcessorHelper {
|
|||
final HashMap<String, String> customTelemetryProperties = new HashMap<>();
|
||||
customTelemetryProperties.put(TelemetryData.SERVICE_NAME, "keyvault");
|
||||
|
||||
this.telemetryProxy.trackEvent(ClassUtils.getUserClass(this.getClass())
|
||||
.getSimpleName(), customTelemetryProperties);
|
||||
final String className = ClassUtils.getUserClass(this.getClass()).getSimpleName();
|
||||
this.telemetryProxy.trackEvent(className, customTelemetryProperties);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class KeyVaultOperation {
|
|||
private final ReadWriteLock rwLock = new ReentrantReadWriteLock();
|
||||
|
||||
public KeyVaultOperation(final KeyVaultClient keyVaultClient, final String vaultUri) {
|
||||
this(keyVaultClient, vaultUri, 1800000L);
|
||||
this(keyVaultClient, vaultUri, Constants.DEFAULT_REFRESH_INTERVAL_MS);
|
||||
}
|
||||
|
||||
public KeyVaultOperation(final KeyVaultClient keyVaultClient, String vaultUri, final long refreshInterval) {
|
||||
|
@ -45,13 +45,11 @@ public class KeyVaultOperation {
|
|||
|
||||
public String[] list() {
|
||||
try {
|
||||
this.rwLock.readLock()
|
||||
.lock();
|
||||
this.rwLock.readLock().lock();
|
||||
return Collections.list(this.propertyNamesHashMap.keys())
|
||||
.toArray(new String[this.propertyNamesHashMap.size()]);
|
||||
} finally {
|
||||
this.rwLock.readLock()
|
||||
.unlock();
|
||||
this.rwLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,12 +82,12 @@ public class KeyVaultOperation {
|
|||
}
|
||||
|
||||
try {
|
||||
this.rwLock.writeLock()
|
||||
.lock();
|
||||
this.rwLock.writeLock().lock();
|
||||
this.propertyNamesHashMap.clear();
|
||||
|
||||
final PagedList<SecretItem> secrets = this.keyVaultClient.listSecrets(this.vaultUri);
|
||||
secrets.loadAll();
|
||||
|
||||
for (final SecretItem secret : secrets) {
|
||||
this.propertyNamesHashMap.putIfAbsent(secret.id()
|
||||
.replaceFirst(this.vaultUri + "/secrets/", "")
|
||||
|
@ -97,10 +95,10 @@ public class KeyVaultOperation {
|
|||
this.propertyNamesHashMap.putIfAbsent(secret.id()
|
||||
.replaceFirst(this.vaultUri + "/secrets/", ""), secret.id());
|
||||
}
|
||||
|
||||
this.lastUpdateTime.set(System.currentTimeMillis());
|
||||
} finally {
|
||||
this.rwLock.writeLock()
|
||||
.unlock();
|
||||
this.rwLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче