[java-opensaml] branch main updated: All HttpResponse types are not closeable, no need to cast.

Scott Cantor cantor.2 at osu.edu
Mon Aug 28 17:47:09 UTC 2023


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=bae63d244bae990e9f496cc7246c4db6256ef354

The following commit(s) were added to refs/heads/main by this push:
     new bae63d244 All HttpResponse types are not closeable, no need to cast.
bae63d244 is described below

commit bae63d244bae990e9f496cc7246c4db6256ef354
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Aug 28 13:47:06 2023 -0400

    All HttpResponse types are not closeable, no need to cast.
---
 .../opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java   | 5 ++---
 .../src/main/java/org/opensaml/soap/client/http/HttpSOAPClient.java  | 5 ++---
 .../soap11/decoder/http/impl/HttpClientResponseSOAP11Decoder.java    | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
index d8b523c91..9f2295920 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/HTTPMetadataResolver.java
@@ -25,7 +25,6 @@ import javax.annotation.Nullable;
 
 import org.apache.hc.client5.http.classic.HttpClient;
 import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -231,8 +230,8 @@ public class HTTPMetadataResolver extends AbstractReloadingMetadataResolver impl
             throw new ResolverException(errMsg, e);
         } finally {
             try {
-                if (response != null && response instanceof CloseableHttpResponse) {
-                    ((CloseableHttpResponse) response).close();
+                if (response != null) {
+                    response.close();
                 }
             } catch (final IOException e) {
                 log.error("{} Error closing HTTP response from {}", metadataURI, getLogPrefix(), e);
diff --git a/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/HttpSOAPClient.java b/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/HttpSOAPClient.java
index 22ac7d3f8..56c91c65a 100644
--- a/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/HttpSOAPClient.java
+++ b/opensaml-soap-api/src/main/java/org/opensaml/soap/client/http/HttpSOAPClient.java
@@ -28,7 +28,6 @@ import javax.xml.namespace.QName;
 
 import org.apache.hc.client5.http.classic.HttpClient;
 import org.apache.hc.client5.http.classic.methods.HttpPost;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.ContentType;
 import org.apache.hc.core5.http.HttpEntity;
@@ -229,8 +228,8 @@ public class HttpSOAPClient extends AbstractInitializableComponent implements SO
                 }
             } finally {
                 try {
-                    if (response != null && response instanceof CloseableHttpResponse) {
-                        ((CloseableHttpResponse)response).close();
+                    if (response != null) {
+                        response.close();
                     }
                 } catch (final IOException e) {
                     log.error("Error closing HttpResponse", e);
diff --git a/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/decoder/http/impl/HttpClientResponseSOAP11Decoder.java b/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/decoder/http/impl/HttpClientResponseSOAP11Decoder.java
index b605369a0..ee59facdb 100644
--- a/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/decoder/http/impl/HttpClientResponseSOAP11Decoder.java
+++ b/opensaml-soap-impl/src/main/java/org/opensaml/soap/client/soap11/decoder/http/impl/HttpClientResponseSOAP11Decoder.java
@@ -21,7 +21,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.xml.namespace.QName;
 
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.opensaml.core.xml.XMLObject;
@@ -128,9 +127,9 @@ public class HttpClientResponseSOAP11Decoder extends BaseHttpClientResponseXMLMe
             log.error("Unable to obtain input stream from HttpResponse: {}", e.getMessage());
             throw new MessageDecodingException("Unable to obtain input stream from HttpResponse", e);
         } finally {
-            if (response instanceof CloseableHttpResponse) {
+            if (response != null) {
                 try {
-                    ((CloseableHttpResponse)response).close();
+                    response.close();
                 } catch (final IOException e) {
                     log.warn("Error closing HttpResponse", e);
                 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list