[java-shib-attribute] branch main updated: OSJ-389: Use try-with-resources for HttpEntity access for HttpClient
Brent Putman
putmanb at georgetown.edu
Thu Aug 31 23:33:39 UTC 2023
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=3e375d480d5462b2629e2910cc7eac7621f40a0f
The following commit(s) were added to refs/heads/main by this push:
new 3e375d480 OSJ-389: Use try-with-resources for HttpEntity access for HttpClient
3e375d480 is described below
commit 3e375d480d5462b2629e2910cc7eac7621f40a0f
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Thu Aug 31 19:32:38 2023 -0400
OSJ-389: Use try-with-resources for HttpEntity access for HttpClient
---
.../http/impl/ScriptedResponseMappingStrategy.java | 27 +++++++++++-----------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/ScriptedResponseMappingStrategy.java b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/ScriptedResponseMappingStrategy.java
index cc256f105..591efda59 100644
--- a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/ScriptedResponseMappingStrategy.java
+++ b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/dc/http/impl/ScriptedResponseMappingStrategy.java
@@ -137,19 +137,20 @@ public final class ScriptedResponseMappingStrategy extends AbstractScriptEvaluat
checkStatus(response);
- final HttpEntity entity = response.getEntity();
- if (entity == null) {
- log.debug("{} Response body was missing", getLogPrefix());
- throw new IOException(getLogPrefix() + " Response body was missing");
- }
-
- checkContentType(entity);
- checkContentLength(entity);
-
- try {
- return (Map<String,IdPAttribute>) evaluate(response);
- } catch (final RuntimeException e) {
- throw new IOException(getLogPrefix() + " Script did not run successfully", e);
+ try (final HttpEntity entity = response.getEntity()) {
+ if (entity == null) {
+ log.debug("{} Response body was missing", getLogPrefix());
+ throw new IOException(getLogPrefix() + " Response body was missing");
+ }
+
+ checkContentType(entity);
+ checkContentLength(entity);
+
+ try {
+ return (Map<String,IdPAttribute>) evaluate(response);
+ } catch (final RuntimeException e) {
+ throw new IOException(getLogPrefix() + " Script did not run successfully", e);
+ }
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list