Skip to content

Commit 58ca912

Browse files
authored
Fix #3406: change default of DeserializationFeature.FAIL_ON_TRAILING_TOKENS to true (#4902)
1 parent c4a1666 commit 58ca912

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

release-notes/VERSION

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Versions: 3.x (for earlier see VERSION-2.x)
6262
#3046: Rename `JsonSerializable` as `JacksonSerializable`
6363
#3047: Rename `Bean[De]SerializerModifier` as `Value[De]SerializerModifier`
6464
#3070: Change default for `SerializationFeature.FAIL_ON_EMPTY_BEANS` to `false`
65+
#3406: Change default of `DeserializationFeature.FAIL_ON_TRAILING_TOKENS` to `true` for 3.0
66+
(suggested by @yawkat)
6567
#3522: Support serializing `ByteArrayOutputStream` as "simple" Binary value
6668
#3536: Create new exception type `JsonNodeException` for use by `JsonNode`-related problems
6769
#3542: Rename "com.fasterxml.jackson" -> "tools.jackson"

src/main/java/tools/jackson/databind/DeserializationFeature.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,9 @@ public enum DeserializationFeature implements ConfigFeature
247247
* for binding the full value, and nothing more (except for possible ignorable
248248
* white space or comments, if supported by data format).
249249
*<p>
250-
* Feature is disabled by default (so that no check is made for possible trailing
251-
* token(s)) for backwards compatibility reasons.
250+
* Feature is enabled by default as of Jackson 3.0 (in 2.x it was disabled).
252251
*/
253-
FAIL_ON_TRAILING_TOKENS(false),
252+
FAIL_ON_TRAILING_TOKENS(true),
254253

255254
/**
256255
* Feature that determines whether Jackson code should catch

src/test/java/tools/jackson/databind/module/SimpleModuleTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ public void testAddModuleWithDeserializerTwiceThenOnlyLatestIsKept() throws Exce
553553
}
554554

555555
@Test
556-
public void testAddModuleWithDeserializerTwiceThenOnlyLatestIsKept_reverseOrder() throws Exception {
556+
public void testAddModuleWithDeserializerTwiceThenOnlyLatestIsKept_reverseOrder() throws Exception
557+
{
557558
SimpleModule firstModule = new SimpleModule()
558559
.addDeserializer(Test3787Bean.class, new Deserializer3787A());
559560
SimpleModule secondModule = new SimpleModule()

src/test/java/tools/jackson/databind/node/TreeReadViaMapperTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void testMultiple() throws Exception
150150
.disable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
151151
.build();
152152
String JSON = "12 \"string\" [ 1, 2, 3 ]";
153-
JsonParser p = mapper.createParser(new StringReader(JSON));
153+
JsonParser p = mapper.createParser(JSON);
154154
JsonNode result = mapper.readTree(p);
155155

156156
assertTrue(result.isIntegralNumber());

0 commit comments

Comments
 (0)