[java-identity-provider] branch master updated: Revert "OSJ-285: Ensure that Closeable instances are actually closed after use"

Brent Putman putmanb at georgetown.edu
Sat Feb 15 05:13:51 EST 2020


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

putmanb pushed a commit to branch master
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=1e0efeebb8142b6550b3f0b1ebd53d41684057f5

The following commit(s) were added to refs/heads/master by this push:
       new  1e0efee   Revert "OSJ-285: Ensure that Closeable instances are actually closed after use"
1e0efee is described below

commit 1e0efeebb8142b6550b3f0b1ebd53d41684057f5
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Sat Feb 15 05:13:16 2020 -0500

    Revert "OSJ-285: Ensure that Closeable instances are actually closed after use"
    
    This reverts commit 70eced7e80ea68116fb4056f6b95ba774eaef23b.
    
    Tests failing, need to evaluate.
---
 .../consent/storage/impl/CollectionSerializer.java | 27 +++++++++++-----------
 .../saml/nameid/impl/TransientIdParameters.java    | 21 +++++++++--------
 .../idp/session/AbstractSPSessionSerializer.java   |  7 ++++--
 .../impl/StorageBackedIdPSessionSerializer.java    |  9 ++++----
 4 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializer.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializer.java
index 21e981e..887c1f4 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializer.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/CollectionSerializer.java
@@ -94,24 +94,23 @@ public class CollectionSerializer extends AbstractInitializableComponent impleme
             @Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key,
             @Nonnull @NotEmpty final String value, @Nullable final Long expiration) throws IOException {
 
-        try (final JsonReader reader = readerFactory.createReader(new StringReader(value))) {
-            final JsonStructure st = reader.read();
-            if (!(st instanceof JsonArray)) {
-                throw new IOException("Found invalid data structure");
-            }
+        final JsonReader reader = readerFactory.createReader(new StringReader(value));
+        final JsonStructure st = reader.read();
+        if (!(st instanceof JsonArray)) {
+            throw new IOException("Found invalid data structure");
+        }
 
-            final Collection<String> collection = new ArrayList<>();
+        final Collection<String> collection = new ArrayList<>();
 
-            for (final JsonValue arrayValue : (JsonArray) st) {
-                if (arrayValue.getValueType().equals(ValueType.STRING)) {
-                    collection.add(((JsonString) arrayValue).getString());
-                }
+        for (final JsonValue arrayValue : (JsonArray) st) {
+            if (arrayValue.getValueType().equals(ValueType.STRING)) {
+                collection.add(((JsonString) arrayValue).getString());
             }
-
-            log.debug("Deserialized context '{}' key '{}' value '{}' expiration '{}' as '{}'", new Object[] {context, key,
-                    value, expiration, collection,});
-            return collection;
         }
+
+        log.debug("Deserialized context '{}' key '{}' value '{}' expiration '{}' as '{}'", new Object[] {context, key,
+                value, expiration, collection,});
+        return collection;
     }
 
 }
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/TransientIdParameters.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/TransientIdParameters.java
index c536b95..82f2a89 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/TransientIdParameters.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/TransientIdParameters.java
@@ -80,17 +80,16 @@ public class TransientIdParameters {
     public TransientIdParameters(@Nonnull @NotEmpty final String encoded) throws IOException {
         Constraint.isNotNull(StringSupport.trimOrNull(encoded), "encoded data must not be null or empty");
 
-        try (final JsonReader reader = Json.createReader(new StringReader(encoded))) {
-            final JsonStructure st = reader.read();
+        final JsonReader reader = Json.createReader(new StringReader(encoded));
+        final JsonStructure st = reader.read();
 
-            if (!(st instanceof JsonObject)) {
-                throw new IOException("Found invalid data structure while parsing IdPSession");
-            }
-            final JsonObject jsonObj = (JsonObject) st;
-
-            principal = jsonObj.getString(PRINCIPAL_FIELD);
-            attributeRecipient = jsonObj.getString(ATTRIBUTE_RECIPIENT_FIELD);
+        if (!(st instanceof JsonObject)) {
+            throw new IOException("Found invalid data structure while parsing IdPSession");
         }
+        final JsonObject jsonObj = (JsonObject) st;
+
+        principal = jsonObj.getString(PRINCIPAL_FIELD);
+        attributeRecipient = jsonObj.getString(ATTRIBUTE_RECIPIENT_FIELD);
     }
 
     /**
@@ -118,7 +117,9 @@ public class TransientIdParameters {
      * @throws IOException if encoding failed
      */
     @Nonnull public String encode() throws IOException {
-        try (final StringWriter sink = new StringWriter(128); final JsonGenerator gen = Json.createGenerator(sink)) {
+        try {
+            final StringWriter sink = new StringWriter(128);
+            final JsonGenerator gen = Json.createGenerator(sink);
             gen.writeStartObject().write(ATTRIBUTE_RECIPIENT_FIELD, getAttributeRecipient())
                     .write(PRINCIPAL_FIELD, getPrincipal());
             gen.writeEnd().close();
diff --git a/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractSPSessionSerializer.java b/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractSPSessionSerializer.java
index 30321bc..b2b910f 100644
--- a/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractSPSessionSerializer.java
+++ b/idp-session-api/src/main/java/net/shibboleth/idp/session/AbstractSPSessionSerializer.java
@@ -71,7 +71,9 @@ public abstract class AbstractSPSessionSerializer extends AbstractInitializableC
 
     /** {@inheritDoc} */
     @Nonnull @NotEmpty public String serialize(@Nonnull final SPSession instance) throws IOException {
-        try (final StringWriter sink = new StringWriter(128); final JsonGenerator gen = Json.createGenerator(sink)) {
+        try {
+            final StringWriter sink = new StringWriter(128);
+            final JsonGenerator gen = Json.createGenerator(sink);
             gen.writeStartObject()
                 .write(SERVICE_ID_FIELD, instance.getId())
                 .write(CREATION_INSTANT_FIELD, instance.getCreationInstant().toEpochMilli());
@@ -96,7 +98,8 @@ public abstract class AbstractSPSessionSerializer extends AbstractInitializableC
             throw new IOException("SPSession objects must have an expiration");
         }
 
-        try (final JsonReader reader = Json.createReader(new StringReader(value))) {
+        try {
+            final JsonReader reader = Json.createReader(new StringReader(value));
             final JsonStructure st = reader.read();
             if (!(st instanceof JsonObject)) {
                 throw new IOException("Found invalid data structure while parsing SPSession");
diff --git a/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/StorageBackedIdPSessionSerializer.java b/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/StorageBackedIdPSessionSerializer.java
index eefe6c3..946b7ea 100644
--- a/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/StorageBackedIdPSessionSerializer.java
+++ b/idp-session-impl/src/main/java/net/shibboleth/idp/session/impl/StorageBackedIdPSessionSerializer.java
@@ -101,9 +101,9 @@ public class StorageBackedIdPSessionSerializer extends AbstractInitializableComp
     @Override @Nonnull @NotEmpty public String serialize(@Nonnull final StorageBackedIdPSession instance)
             throws IOException {
 
-        try (final StringWriter sink = new StringWriter(128);
-                final JsonGenerator gen = jsonProvider.createGenerator(sink)) {
-            
+        try {
+            final StringWriter sink = new StringWriter(128);
+            final JsonGenerator gen = jsonProvider.createGenerator(sink);
             gen.writeStartObject().write(CREATION_INSTANT_FIELD, instance.getCreationInstant().toEpochMilli())
                     .write(PRINCIPAL_NAME_FIELD, instance.getPrincipalName());
 
@@ -158,7 +158,8 @@ public class StorageBackedIdPSessionSerializer extends AbstractInitializableComp
             throw new IOException("IdPSession objects must have an expiration");
         }
 
-        try (final JsonReader reader = jsonProvider.createReader(new StringReader(value))) {
+        try {
+            final JsonReader reader = jsonProvider.createReader(new StringReader(value));
             final JsonStructure st = reader.read();
             if (!(st instanceof JsonObject)) {
                 throw new IOException("Found invalid data structure while parsing IdPSession");

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


More information about the commits mailing list