From b789bf2258c5e39f7ad52d7671c34a4980e8ea67 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 26 Jan 2021 20:15:09 -0800 Subject: [PATCH] Fix #663 --- release-notes/VERSION | 1 + .../jackson/core/base/ParserMinimalBase.java | 4 ++-- .../UnexpectedEndOfInputException.java} | 13 ++++++------- .../com/fasterxml/jackson/core/TestExceptions.java | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) rename src/main/java/com/fasterxml/jackson/core/{io/JsonEOFException.java => exc/UnexpectedEndOfInputException.java} (66%) diff --git a/release-notes/VERSION b/release-notes/VERSION index 665a9fe54e..31e72a49b6 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -26,6 +26,7 @@ JSON library. #456: Add `JsonParser.readAsValue(ResolvedType)` #492: Ensure primitive type names in error message enclosed in backticks #551: Remove `JsonGenerator.setPrettyPrinter()` from 3.0 +#663: Rename `JsonEOFException` as `UnexpectedEndOfInputException` #670: Replace references to "field" in `JsonGenerator`, `JsonParser` method names with "property" #671: Replace `getCurrentLocation()`/`getTokenLocation()` with `currentLocation()`/`currentTokenLocation()` diff --git a/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java b/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java index 6417e7a15b..fac84d20f1 100644 --- a/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java +++ b/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java @@ -7,9 +7,9 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.exc.InputCoercionException; +import com.fasterxml.jackson.core.exc.UnexpectedEndOfInputException; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.exc.WrappedIOException; -import com.fasterxml.jackson.core.io.JsonEOFException; import com.fasterxml.jackson.core.io.NumberInput; import com.fasterxml.jackson.core.sym.PropertyNameMatcher; import com.fasterxml.jackson.core.type.ResolvedType; @@ -896,7 +896,7 @@ protected void _reportInvalidEOFInValue(JsonToken type) throws StreamReadExcepti } protected void _reportInvalidEOF(String msg, JsonToken currToken) throws StreamReadException { - throw new JsonEOFException(this, currToken, "Unexpected end-of-input"+msg); + throw new UnexpectedEndOfInputException(this, currToken, "Unexpected end-of-input"+msg); } protected void _reportMissingRootWS(int ch) throws StreamReadException { diff --git a/src/main/java/com/fasterxml/jackson/core/io/JsonEOFException.java b/src/main/java/com/fasterxml/jackson/core/exc/UnexpectedEndOfInputException.java similarity index 66% rename from src/main/java/com/fasterxml/jackson/core/io/JsonEOFException.java rename to src/main/java/com/fasterxml/jackson/core/exc/UnexpectedEndOfInputException.java index c21eafacb9..978f9f46a1 100644 --- a/src/main/java/com/fasterxml/jackson/core/io/JsonEOFException.java +++ b/src/main/java/com/fasterxml/jackson/core/exc/UnexpectedEndOfInputException.java @@ -1,16 +1,15 @@ -package com.fasterxml.jackson.core.io; +package com.fasterxml.jackson.core.exc; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.core.exc.StreamReadException; /** * Specialized {@link StreamReadException} that is thrown when end-of-input - * is reached unexpectedly, either within token being decoded, or during - * skipping of intervening white-space that is not between root-level - * tokens (that is, is within JSON Object or JSON Array construct). + * is reached unexpectedly, usually within token being decoded, but possibly + * within intervening non-token content (for formats that have that, such + * as whitespace for textual formats) */ -public class JsonEOFException +public class UnexpectedEndOfInputException extends StreamReadException { private static final long serialVersionUID = 3L; @@ -21,7 +20,7 @@ public class JsonEOFException */ protected final JsonToken _token; - public JsonEOFException(JsonParser p, JsonToken token, String msg) { + public UnexpectedEndOfInputException(JsonParser p, JsonToken token, String msg) { super(p, msg); _token = token; } diff --git a/src/test/java/com/fasterxml/jackson/core/TestExceptions.java b/src/test/java/com/fasterxml/jackson/core/TestExceptions.java index 48608050df..64fb334d97 100644 --- a/src/test/java/com/fasterxml/jackson/core/TestExceptions.java +++ b/src/test/java/com/fasterxml/jackson/core/TestExceptions.java @@ -2,9 +2,9 @@ import java.io.StringWriter; +import com.fasterxml.jackson.core.exc.UnexpectedEndOfInputException; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.core.exc.StreamWriteException; -import com.fasterxml.jackson.core.io.JsonEOFException; import com.fasterxml.jackson.core.json.JsonFactory; public class TestExceptions extends BaseTest @@ -79,7 +79,7 @@ private void _testEofExceptions(int mode) throws Exception try { p.nextToken(); fail("Should get exception"); - } catch (JsonEOFException e) { + } catch (UnexpectedEndOfInputException e) { verifyException(e, "close marker for Array"); } p.close(); @@ -92,7 +92,7 @@ private void _testEofExceptions(int mode) throws Exception try { p.nextToken(); fail("Should get exception"); - } catch (JsonEOFException e) { + } catch (UnexpectedEndOfInputException e) { verifyException(e, "close marker for Object"); } p.close(); @@ -102,7 +102,7 @@ private void _testEofExceptions(int mode) throws Exception try { p.nextToken(); fail("Should get exception"); - } catch (JsonEOFException e) { + } catch (UnexpectedEndOfInputException e) { verifyException(e, "in property name"); assertEquals(JsonToken.PROPERTY_NAME, e.getTokenBeingDecoded()); @@ -114,7 +114,7 @@ private void _testEofExceptions(int mode) throws Exception try { p.nextToken(); fail("Should get exception"); - } catch (JsonEOFException e) { + } catch (UnexpectedEndOfInputException e) { verifyException(e, "unexpected end-of-input"); verifyException(e, "Object entries"); }