From 6982e5cf95e78392249ac43d8da70326522c02e0 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 6 Jan 2025 19:44:38 -0800 Subject: [PATCH 1/2] 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/2] 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());