Skip to content

Commit ebdeaf0

Browse files
committed
Polishing
1 parent 5d138a1 commit ebdeaf0

File tree

7 files changed

+7
-21
lines changed

7 files changed

+7
-21
lines changed

spring-vault-core/src/main/java/org/springframework/vault/client/ClientConfiguration.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,8 @@ private static void loadKeyStore(SslConfiguration.KeyStoreConfiguration keyStore
150150
logger.debug("Loading keystore from %s".formatted(keyStoreConfiguration.getResource()));
151151
}
152152

153-
InputStream inputStream = null;
154-
try {
155-
inputStream = keyStoreConfiguration.getResource().getInputStream();
153+
try (InputStream inputStream = keyStoreConfiguration.getResource()
154+
.getInputStream()) {
156155

157156
if (SslConfiguration.PEM_KEYSTORE_TYPE.equalsIgnoreCase(keyStoreConfiguration.getStoreType())) {
158157

@@ -167,11 +166,6 @@ private static void loadKeyStore(SslConfiguration.KeyStoreConfiguration keyStore
167166
logger.debug("Keystore loaded with %d entries".formatted(keyStore.size()));
168167
}
169168
}
170-
finally {
171-
if (inputStream != null) {
172-
inputStream.close();
173-
}
174-
}
175169
}
176170

177171
private static void loadFromPem(KeyStore keyStore, InputStream inputStream) throws IOException, KeyStoreException {

spring-vault-core/src/main/java/org/springframework/vault/client/ClientHttpRequestFactoryFactory.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
import javax.net.ssl.SSLContext;
3535

36-
import org.apache.commons.logging.Log;
37-
import org.apache.commons.logging.LogFactory;
3836
import org.apache.hc.client5.http.config.ConnectionConfig;
3937
import org.apache.hc.client5.http.config.RequestConfig;
4038
import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
@@ -76,9 +74,6 @@
7674
*/
7775
public class ClientHttpRequestFactoryFactory {
7876

79-
@SuppressWarnings("FieldMayBeFinal") // allow setting via reflection.
80-
private static Log logger = LogFactory.getLog(ClientHttpRequestFactoryFactory.class);
81-
8277
private static final boolean reactorNettyPresent = ClassUtils.isPresent("reactor.netty.http.client.HttpClient",
8378
ClientHttpConnectorFactory.class.getClassLoader());
8479

spring-vault-core/src/main/java/org/springframework/vault/client/VaultClients.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static String prepareUriTemplate(@Nullable String baseUrl, String uriTemplate) {
217217
return uriTemplate;
218218
}
219219
}
220-
catch (IllegalArgumentException e) {
220+
catch (IllegalArgumentException ignored) {
221221
}
222222

223223
if (!uriTemplate.startsWith("/")) {

spring-vault-core/src/main/java/org/springframework/vault/client/VaultResponses.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public Type getOwnerType() {
126126
}
127127
};
128128

129-
return new ParameterizedTypeReference<VaultResponseSupport<T>>() {
129+
return new ParameterizedTypeReference<>() {
130130
@Override
131131
public Type getType() {
132132
return supportType;
@@ -179,7 +179,7 @@ public static <T> T unwrap(final String wrappedResponse, Class<T> responseType)
179179
try {
180180
return (T) converter.read(responseType, new HttpInputMessage() {
181181
@Override
182-
public InputStream getBody() throws IOException {
182+
public InputStream getBody() {
183183
return new ByteArrayInputStream(wrappedResponse.getBytes());
184184
}
185185

spring-vault-core/src/main/java/org/springframework/vault/config/AbstractReactiveVaultConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ protected VaultTokenSupplier vaultTokenSupplier() {
206206
return CachingVaultTokenSupplier.of(stepsOperator);
207207
}
208208

209-
throw new IllegalStateException("Cannot construct VaultTokenSupplier from %s. "
210-
+ "ClientAuthentication must implement AuthenticationStepsFactory or be TokenAuthentication"
209+
throw new IllegalStateException(("Cannot construct VaultTokenSupplier from %s. "
210+
+ "ClientAuthentication must implement AuthenticationStepsFactory or be TokenAuthentication")
211211
.formatted(clientAuthentication));
212212
}
213213

spring-vault-core/src/main/java/org/springframework/vault/config/EnvironmentVaultConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ public ClientAuthentication clientAuthentication() {
269269
case CERT -> new ClientCertificateAuthentication(restOperations());
270270
case CUBBYHOLE -> cubbyholeAuthentication();
271271
case KUBERNETES -> kubeAuthentication();
272-
default -> throw new IllegalStateException("Vault authentication method %s is not supported with %s"
273-
.formatted(authenticationMethod, getClass().getSimpleName()));
274272
};
275273
}
276274

spring-vault-core/src/main/java/org/springframework/vault/core/VaultTokenTemplate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ private <T extends VaultResponseSupport<?>> T writeAndReturn(String path, @Nulla
123123
return response;
124124
}
125125

126-
@Nullable
127126
private void writeToken(String path, VaultToken token, Class<?> responseType) {
128127

129128
Assert.hasText(path, "Path must not be empty");

0 commit comments

Comments
 (0)