File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed
cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments