[spring-extensions] branch master updated: Refactoring related to last commit on response closing.

Brent Putman putmanb at georgetown.edu
Wed Apr 20 16:14:46 EDT 2016


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

putmanb pushed a commit to branch master
in repository spring-extensions.

The following commit(s) were added to refs/heads/master by this push:
       new  ba15de2   Refactoring related to last commit on response closing.
ba15de2 is described below

commit ba15de29e1a08a2e15109c60bc26e4223068ace5
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Apr 20 16:13:38 2016 -0400

    Refactoring related to last commit on response closing.
    
    Move new method up before inner class.
    Make consistent use of the new method for closing response.
---
 .../ext/spring/resource/HTTPResource.java          | 38 +++++++++-------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/resource/HTTPResource.java b/src/main/java/net/shibboleth/ext/spring/resource/HTTPResource.java
index 8425942..05e6a3a 100644
--- a/src/main/java/net/shibboleth/ext/spring/resource/HTTPResource.java
+++ b/src/main/java/net/shibboleth/ext/spring/resource/HTTPResource.java
@@ -245,13 +245,7 @@ public class HTTPResource extends AbstractIdentifiedInitializableComponent imple
         } catch (IOException e) {
             throw new IOException("Error contacting remote resource " + resourceURL.toString(), e);
         } finally {
-            try {
-                if (httpResponse != null && httpResponse instanceof CloseableHttpResponse) {
-                    ((CloseableHttpResponse)httpResponse).close();
-                }
-            } catch (final IOException e) {
-                log.error("Error closing HTTP response from {}", resourceURL.toExternalForm(), e);
-            }
+            closeResponse(httpResponse);
         }
     }
 
@@ -344,6 +338,21 @@ public class HTTPResource extends AbstractIdentifiedInitializableComponent imple
     }
     
     /**
+     * Close the HTTP response.
+     * 
+     * @param response the HTTP response
+     */
+    protected void closeResponse(@Nullable final HttpResponse response) {
+        try {
+            if (response != null && response instanceof CloseableHttpResponse) {
+                ((CloseableHttpResponse) response).close();
+            }
+        } catch (final IOException e) {
+            log.error("Error closing HTTP response from '{}'", resourceURL.toExternalForm(), e);
+        }
+    }
+    
+    /**
      * A wrapper around the entity content {@link InputStream} represented by an {@link HttpResponse}
      * that closes the stream and the HttpResponse when {@link #close()} is invoked.
      */
@@ -415,19 +424,4 @@ public class HTTPResource extends AbstractIdentifiedInitializableComponent imple
         }
     }
 
-    /**
-     * Close the HTTP response.
-     * 
-     * @param response the HTTP response
-     */
-    protected void closeResponse(@Nullable final HttpResponse response) {
-        try {
-            if (response != null && response instanceof CloseableHttpResponse) {
-                ((CloseableHttpResponse) response).close();
-            }
-        } catch (final IOException e) {
-            log.error("Error closing HTTP response from '{}'", resourceURL.toExternalForm(), e);
-        }
-    }
-
 }

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


More information about the commits mailing list