Skip to content

Commit 9edbdd8

Browse files
added close for PMD 2
1 parent a276a71 commit 9edbdd8

File tree

1 file changed

+5
-15
lines changed
  • cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity

1 file changed

+5
-15
lines changed

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,28 +292,18 @@ private static TransparentProxyDestination verifyDestination(
292292
"Performing HEAD request to destination with name {} to verify the destination exists",
293293
destinationName);
294294
final Supplier<ClassicHttpResponse> tpDestinationVerifierSupplier = prepareSupplier(httpClient, headRequest);
295-
ClassicHttpResponse response = null;
296-
try {
297-
response = ResilienceDecorator.executeSupplier(tpDestinationVerifierSupplier, resilienceConfiguration);
295+
try(
296+
final ClassicHttpResponse response =
297+
ResilienceDecorator.executeSupplier(tpDestinationVerifierSupplier, resilienceConfiguration) ) {
298298
verifyTransparentProxyResponse(response, destinationName);
299+
EntityUtils.consume(response.getEntity());
299300
}
300-
catch( final ResilienceRuntimeException e ) {
301+
catch( final ResilienceRuntimeException | IOException e ) {
301302
if( hasCauseAssignableFrom(e, DestinationNotFoundException.class) ) {
302303
throw new DestinationNotFoundException(e);
303304
}
304305
throw new DestinationAccessException(e);
305306
}
306-
finally {
307-
if( response != null ) {
308-
try {
309-
EntityUtils.consume(response.getEntity());
310-
response.close();
311-
}
312-
catch( IOException e ) {
313-
log.warn("Failed to close HTTP response", e);
314-
}
315-
}
316-
}
317307

318308
return destination;
319309
}

0 commit comments

Comments
 (0)