This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git


The following commit(s) were added to refs/heads/master by this push:
     new 86e9a1e  don't eagerly close the underlying stream of a reader
86e9a1e is described below

commit 86e9a1ede3d321c3074bb51e681193c61f4e888c
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Mon Aug 19 15:06:25 2019 +0200

    don't eagerly close the underlying stream of a reader
---
 .../org/apache/johnzon/core/JsonReaderImpl.java    | 53 ++++++----------------
 1 file changed, 15 insertions(+), 38 deletions(-)

diff --git 
a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonReaderImpl.java 
b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonReaderImpl.java
index 57bb5a3..71bd0e1 100644
--- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonReaderImpl.java
+++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonReaderImpl.java
@@ -76,7 +76,7 @@ public class JsonReaderImpl implements JsonReader {
         }
 
 
-        JsonParser.Event next;
+        final JsonParser.Event next;
         if (subStreamReader) {
             next = parser.current();
         } else {
@@ -87,54 +87,36 @@ public class JsonReaderImpl implements JsonReader {
             case START_OBJECT:
                 final JsonObjectBuilder objectBuilder = new 
JsonObjectBuilderImpl(emptyMap(), bufferProvider);
                 parseObject(objectBuilder);
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return objectBuilder.build();
             case START_ARRAY:
                 final JsonArrayBuilder arrayBuilder = new 
JsonArrayBuilderImpl(emptyList(), bufferProvider);
                 parseArray(arrayBuilder);
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return arrayBuilder.build();
             case VALUE_STRING:
                 final JsonStringImpl string = new 
JsonStringImpl(parser.getString());
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return string;
             case VALUE_FALSE:
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return JsonValue.FALSE;
             case VALUE_TRUE:
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return JsonValue.TRUE;
             case VALUE_NULL:
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return JsonValue.NULL;
             case VALUE_NUMBER:
@@ -144,11 +126,8 @@ public class JsonReaderImpl implements JsonReader {
                 } else {
                     number = new JsonNumberImpl(parser.getBigDecimal());
                 }
-                if (!subStreamReader) {
-                    if (parser.hasNext()) {
-                        throw new JsonParsingException("Expected end of file", 
parser.getLocation());
-                    }
-                    close();
+                if (!subStreamReader && parser.hasNext()) {
+                    throw new JsonParsingException("Expected end of file", 
parser.getLocation());
                 }
                 return number;
             default:
@@ -179,12 +158,10 @@ public class JsonReaderImpl implements JsonReader {
 
     @Override
     public void close() {
-
         if (!closed) {
             closed = true;
             parser.close();
         }
-
     }
 
     private void parseObject(final JsonObjectBuilder builder) {

Reply via email to