Skip to content

Commit 7fe5f5a

Browse files
committed
Sync with jackson-core changes wrt StreamReadConstraints
1 parent 82a0db9 commit 7fe5f5a

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroParserImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,5 +624,5 @@ protected final JsonToken setNumber(double v) {
624624
return JsonToken.VALUE_NUMBER_FLOAT;
625625
}
626626

627-
protected abstract JsonToken setString(String str);
627+
protected abstract JsonToken setString(String str) throws IOException;
628628
}

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/JacksonAvroParserImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ public boolean checkInputEnd() throws IOException {
10111011
*/
10121012

10131013
@Override
1014-
protected JsonToken setString(String str) {
1014+
protected JsonToken setString(String str) throws IOException {
10151015
_textBuffer.resetWithString(str);
10161016
return JsonToken.VALUE_STRING;
10171017
}

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/ScalarDefaults.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public StringDefaults(String name, String v) {
5353
}
5454

5555
@Override
56-
public JsonToken readValue(AvroReadContext parent, AvroParserImpl parser) {
56+
public JsonToken readValue(AvroReadContext parent, AvroParserImpl parser) throws IOException {
5757
return parser.setString(_defaults);
5858
}
5959
}

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/RoundtripTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.core.JsonGenerator;
44

55
import com.fasterxml.jackson.core.StreamReadConstraints;
6+
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
67
import com.fasterxml.jackson.databind.*;
78

89
public class RoundtripTest extends MapTest
@@ -102,8 +103,8 @@ public void testCharSequencesLowStringLimit() throws Exception
102103
try {
103104
mapper.reader(CHARSEQ_SCHEMA)
104105
.forType(CharSeqBean.class).readValue(avroData);
105-
fail("expected IllegalStateException");
106-
} catch (IllegalStateException ise) {
106+
fail("expected StreamConstraintsException");
107+
} catch (StreamConstraintsException ise) {
107108
assertEquals("String length (3) exceeds the maximum length (1)", ise.getMessage());
108109
}
109110
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParserNumbersTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.fasterxml.jackson.core.*;
99
import com.fasterxml.jackson.core.JsonParser.NumberType;
10+
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
1011
import com.fasterxml.jackson.dataformat.cbor.*;
1112
import com.fasterxml.jackson.dataformat.cbor.testutil.ThrottledInputStream;
1213

@@ -371,9 +372,9 @@ public void testVeryBigDecimalType() throws IOException {
371372
try (CBORParser parser = cborParser(b)) {
372373
try {
373374
parser.nextToken();
374-
fail("expected NumberFormatException");
375-
} catch (NumberFormatException nfe) {
376-
assertEquals("Number length (4153) exceeds the maximum length (1000)", nfe.getMessage());
375+
fail("expected StreamConstraintsException");
376+
} catch (StreamConstraintsException e) {
377+
assertEquals("Number length (4153) exceeds the maximum length (1000)", e.getMessage());
377378
}
378379
}
379380
}

cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/seq/ReadTreesTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.List;
44

55
import com.fasterxml.jackson.core.StreamReadConstraints;
6+
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
67
import com.fasterxml.jackson.databind.*;
78

89
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
@@ -82,7 +83,7 @@ public void testReadTreeSequenceLowStringLimit() throws Exception
8283
try {
8384
it.nextValue();
8485
fail("expected IllegalStateException");
85-
} catch (IllegalStateException ise) {
86+
} catch (StreamConstraintsException ise) {
8687
assertEquals("String length (2) exceeds the maximum length (1)", ise.getMessage());
8788
}
8889
}

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/async/SimpleStringArrayTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.fasterxml.jackson.core.JsonGenerator;
77
import com.fasterxml.jackson.core.JsonToken;
88
import com.fasterxml.jackson.core.StreamReadConstraints;
9+
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
910
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
1011
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
1112
import com.fasterxml.jackson.dataformat.smile.SmileParser;
@@ -134,8 +135,8 @@ public void testLongAsciiStringsLowStringLimit() throws IOException
134135
assertToken(JsonToken.VALUE_STRING, r.nextToken());
135136
try {
136137
r.currentText();
137-
fail("expected IllegalStateException");
138-
} catch (IllegalStateException ise) {
138+
fail("expected StreamConstraintsException");
139+
} catch (StreamConstraintsException ise) {
139140
assertEquals("String length (98) exceeds the maximum length (10)", ise.getMessage());
140141
}
141142
}

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/parse/NumberParsingTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.math.BigInteger;
66

77
import com.fasterxml.jackson.core.*;
8+
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
89
import com.fasterxml.jackson.dataformat.smile.BaseTestForSmile;
910
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
1011
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
@@ -397,8 +398,8 @@ public void testVeryBigDecimal() throws IOException
397398
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
398399
try {
399400
p.getNumberType();
400-
fail("expected NumberFormatException");
401-
} catch (NumberFormatException nfe) {
401+
fail("expected StreamConstraintsException");
402+
} catch (StreamConstraintsException nfe) {
402403
assertEquals("Number length (4153) exceeds the maximum length (1000)", nfe.getMessage());
403404
}
404405
}

0 commit comments

Comments
 (0)