Polishing

This commit is contained in:
Mark Paluch
2025-02-18 15:35:14 +01:00
parent 5d138a105e
commit ebdeaf0592
7 changed files with 7 additions and 21 deletions

View File

@@ -150,9 +150,8 @@ class ClientConfiguration {
logger.debug("Loading keystore from %s".formatted(keyStoreConfiguration.getResource()));
}
InputStream inputStream = null;
try {
inputStream = keyStoreConfiguration.getResource().getInputStream();
try (InputStream inputStream = keyStoreConfiguration.getResource()
.getInputStream()) {
if (SslConfiguration.PEM_KEYSTORE_TYPE.equalsIgnoreCase(keyStoreConfiguration.getStoreType())) {
@@ -167,11 +166,6 @@ class ClientConfiguration {
logger.debug("Keystore loaded with %d entries".formatted(keyStore.size()));
}
}
finally {
if (inputStream != null) {
inputStream.close();
}
}
}
private static void loadFromPem(KeyStore keyStore, InputStream inputStream) throws IOException, KeyStoreException {

View File

@@ -33,8 +33,6 @@ import java.security.KeyStore;
import javax.net.ssl.SSLContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
@@ -76,9 +74,6 @@ import static org.springframework.vault.client.ClientConfiguration.*;
*/
public class ClientHttpRequestFactoryFactory {
@SuppressWarnings("FieldMayBeFinal") // allow setting via reflection.
private static Log logger = LogFactory.getLog(ClientHttpRequestFactoryFactory.class);
private static final boolean reactorNettyPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient",
ClientHttpConnectorFactory.class.getClassLoader());

View File

@@ -217,7 +217,7 @@ public class VaultClients {
return uriTemplate;
}
}
catch (IllegalArgumentException e) {
catch (IllegalArgumentException ignored) {
}
if (!uriTemplate.startsWith("/")) {

View File

@@ -126,7 +126,7 @@ public abstract class VaultResponses {
}
};
return new ParameterizedTypeReference<VaultResponseSupport<T>>() {
return new ParameterizedTypeReference<>() {
@Override
public Type getType() {
return supportType;
@@ -179,7 +179,7 @@ public abstract class VaultResponses {
try {
return (T) converter.read(responseType, new HttpInputMessage() {
@Override
public InputStream getBody() throws IOException {
public InputStream getBody() {
return new ByteArrayInputStream(wrappedResponse.getBytes());
}

View File

@@ -206,8 +206,8 @@ public abstract class AbstractReactiveVaultConfiguration extends AbstractVaultCo
return CachingVaultTokenSupplier.of(stepsOperator);
}
throw new IllegalStateException("Cannot construct VaultTokenSupplier from %s. "
+ "ClientAuthentication must implement AuthenticationStepsFactory or be TokenAuthentication"
throw new IllegalStateException(("Cannot construct VaultTokenSupplier from %s. "
+ "ClientAuthentication must implement AuthenticationStepsFactory or be TokenAuthentication")
.formatted(clientAuthentication));
}

View File

@@ -269,8 +269,6 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration im
case CERT -> new ClientCertificateAuthentication(restOperations());
case CUBBYHOLE -> cubbyholeAuthentication();
case KUBERNETES -> kubeAuthentication();
default -> throw new IllegalStateException("Vault authentication method %s is not supported with %s"
.formatted(authenticationMethod, getClass().getSimpleName()));
};
}

View File

@@ -123,7 +123,6 @@ public class VaultTokenTemplate implements VaultTokenOperations {
return response;
}
@Nullable
private void writeToken(String path, VaultToken token, Class<?> responseType) {
Assert.hasText(path, "Path must not be empty");