From 6982e5cf95e78392249ac43d8da70326522c02e0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jan 2025 19:44:38 -0800 Subject: [PATCH 1/4] Fix #1484: change `MapperFeature.DEFAULT_VIEW_INCLUSION` default to `false` --- release-notes/VERSION | 1 + src/main/java/tools/jackson/databind/MapperFeature.java | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index f759db6551..d5afb9f8ab 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -11,6 +11,7 @@ Versions: 3.x (for earlier see VERSION-2.x) (contributed by Joo-Hyuk K) #1058: Add a way to pass std and format-specific parser/generator flags during parser/generation construction +#1484: Changed default of `MapperFeature.DEFAULT_VIEW_INCLUSION` to `false` in 3.0 #1600: Serializing locale with underscore, not standard hyphen (requested by Alexander K) #1762: `StdDateFormat`: serialize time offset using colon diff --git a/src/main/java/tools/jackson/databind/MapperFeature.java b/src/main/java/tools/jackson/databind/MapperFeature.java index d331b98ea1..6cf907ee33 100644 --- a/src/main/java/tools/jackson/databind/MapperFeature.java +++ b/src/main/java/tools/jackson/databind/MapperFeature.java @@ -259,13 +259,12 @@ public enum MapperFeature * changes between "opt-in" (feature disabled) and * "opt-out" (feature enabled) modes. *

- * Default value is enabled, meaning that non-annotated - * properties are included in all views if there is no + * Feature is disabled by default as of Jackson 3.0 (in 2.x it was enabled), + * meaning that non-annotated + * properties are not included views if there is no * {@link com.fasterxml.jackson.annotation.JsonView} annotation. - *

- * Feature is enabled by default. */ - DEFAULT_VIEW_INCLUSION(true), + DEFAULT_VIEW_INCLUSION(false), /* /********************************************************************** From eade1813adce014bff8d16b808753f1775981efc Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Fri, 31 Jan 2025 14:27:52 -0800 Subject: [PATCH 2/4] Minor test improvement --- .../deser/jdk/CollectionDeserTest.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/test/java/tools/jackson/databind/deser/jdk/CollectionDeserTest.java b/src/test/java/tools/jackson/databind/deser/jdk/CollectionDeserTest.java index b80d450647..e75c2fa2c8 100644 --- a/src/test/java/tools/jackson/databind/deser/jdk/CollectionDeserTest.java +++ b/src/test/java/tools/jackson/databind/deser/jdk/CollectionDeserTest.java @@ -266,32 +266,42 @@ public void testIterableWithBeans() throws Exception // for [databind#506] @Test - public void testArrayIndexForExceptions() throws Exception + public void testArrayIndexForExceptions1() throws Exception { - final String OBJECTS_JSON = "[ \"KEY2\", false ]"; try { - MAPPER.readValue(OBJECTS_JSON, Key[].class); + MAPPER.readValue("[ \"KEY2\", false ]", Key[].class); fail("Should not pass"); } catch (MismatchedInputException e) { - verifyException(e, "Cannot deserialize"); + verifyException(e, "Cannot deserialize value of type"); + verifyException(e, "from Boolean value"); assertEquals(1, e.getPath().size()); assertEquals(1, e.getPath().get(0).getIndex()); } + } + @Test + public void testArrayIndexForExceptions2() throws Exception + { try { MAPPER.readValue("[ \"xyz\", { } ]", String[].class); fail("Should not pass"); } catch (MismatchedInputException e) { - verifyException(e, "Cannot deserialize"); + verifyException(e, "Cannot deserialize value of type"); + verifyException(e, "from Object value"); assertEquals(1, e.getPath().size()); assertEquals(1, e.getPath().get(0).getIndex()); } + } + @Test + public void testArrayIndexForExceptions3() throws Exception + { try { - MAPPER.readValue("{\"keys\":"+OBJECTS_JSON+"}", KeyListBean.class); + MAPPER.readValue("{\"keys\":[ \"KEY2\", false ]}", KeyListBean.class); fail("Should not pass"); } catch (MismatchedInputException e) { - verifyException(e, "Cannot deserialize"); + verifyException(e, "Cannot deserialize value of type"); + verifyException(e, "from Boolean value"); assertEquals(2, e.getPath().size()); // Bean has no index, but has name: assertEquals(-1, e.getPath().get(0).getIndex()); From d52f88344ff79b50197039bc3a4c72e802f8ef01 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 30 Apr 2025 15:59:03 -0700 Subject: [PATCH 3/4] Update release notes --- release-notes/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index 32760ae5a2..37256520ab 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -7,6 +7,7 @@ Versions: 3.x (for earlier see VERSION-2.x) 3.0.0-rc4 (not yet released) +#1484: Changed default of `MapperFeature.DEFAULT_VIEW_INCLUSION` to `false` in 3.0 #5093: Change the way `BeanDescription` passed during serializer construction to use `Supplier` #5094: Change the way `BeanDescription` passed during deserializer construction @@ -56,7 +57,6 @@ Versions: 3.x (for earlier see VERSION-2.x) (contributed by Joo-Hyuk K) #1058: Add a way to pass std and format-specific parser/generator flags during parser/generation construction -#1484: Changed default of `MapperFeature.DEFAULT_VIEW_INCLUSION` to `false` in 3.0 #1600: Serializing locale with underscore, not standard hyphen (requested by Alexander K) #1762: `StdDateFormat`: serialize time offset using colon From f5bf7b211ecc807880f9b7d58fd2cae2e71e546c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 30 Apr 2025 16:03:10 -0700 Subject: [PATCH 4/4] ... --- .../java/tools/jackson/databind/DeserializationFeature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tools/jackson/databind/DeserializationFeature.java b/src/main/java/tools/jackson/databind/DeserializationFeature.java index 38d7970568..415352049a 100644 --- a/src/main/java/tools/jackson/databind/DeserializationFeature.java +++ b/src/main/java/tools/jackson/databind/DeserializationFeature.java @@ -296,7 +296,7 @@ public enum DeserializationFeature implements ConfigFeature * by ensuring that only the properties relevant to the active view are considered during * deserialization, thereby preventing unintended data from being processed. *

- * Feature is enabled by default. + * Feature is enabled by default in Jackson 3.x (in 2.x it was disabled by default). */ FAIL_ON_UNEXPECTED_VIEW_PROPERTIES(true),