Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default of MapperFeature.DEFAULT_VIEW_INCLUSION to false in 3.0 #1484

Open
sdeleuze opened this issue Dec 29, 2016 · 7 comments
Open
Labels
3.0 Issue planned for initial 3.0 release

Comments

@sdeleuze
Copy link

In Jackson 2.x, MapperFeature.DEFAULT_VIEW_INCLUSION is set to true by default, but almost all users set it to false because the most common use case is to only keep properties or fields annotated with @JsonView.

In Spring Framework and Spring Boot, we already modify this default value, but maybe the default setting could be modify in Jackson 3.x in order to avoid confusing users?

@cowtowncoder cowtowncoder added the 3.x Issues to be only tackled for Jackson 3.x, not 2.x label Jan 6, 2017
@cowtowncoder
Copy link
Member

Thank you for suggesting this: I hope to focus bit more on 3.x planning after getting 2.9 finalized.
It's great to have these entries as a starting point. Next step would probably be to either create a new repo, or to use a wiki of existing repos (maybe jackson-docs or jackson or just jackson-databind); either way, having a collaborative sharing environment for collecting ideas and plans.

@cowtowncoder cowtowncoder changed the title (for Jackson 3.x) Reconsider MapperFeature.DEFAULT_VIEW_INCLUSION default setting Consider changing MapperFeature.DEFAULT_VIEW_INCLUSION default setting Dec 1, 2024
@cowtowncoder cowtowncoder added 3.0 Issue planned for initial 3.0 release and removed 3.x Issues to be only tackled for Jackson 3.x, not 2.x labels Dec 1, 2024
@cowtowncoder cowtowncoder changed the title Consider changing MapperFeature.DEFAULT_VIEW_INCLUSION default setting Changed default of MapperFeature.DEFAULT_VIEW_INCLUSION to false in 3.0 Dec 12, 2024
@cowtowncoder
Copy link
Member

Being discussed here:

based on which change will either made, or not.

@cowtowncoder
Copy link
Member

Discussion closed: will proceed with this change.

@JooHyukKim
Copy link
Member

JooHyukKim commented Jan 7, 2025

@cowtowncoder let's add below to JSTEP-2. Leaving this here because, Currently laptop is blocked to edit anything from github.com. Will comeback and pick this up in 2 days 🥲.

* `DEFAULT_VIEW_INCLUSION`: default to `false` (because the most common use case is to only keep properties or fields annotated with `@JsonView`.)
    * [databind#1484](https://github.com/FasterXML/jackson-databind/issues/1484)

@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 7, 2025

@JooHyukKim Will add once it gets completed -- having some problems with PR (#4885).

Basically PR initially had 12 fails; could fix/work-around 7 by configuring ObjectMapper for tests, but while all could in theory be patched, there does seem to be something odd in "not included by default" mode, changing behavior when there should be no change.
Some of failures happen in 2.19 as well but not all -- and none of these make immediate sense.

@JooHyukKim
Copy link
Member

Right, I pulled and checked. Below tests are failing.

[ERROR] Failures: 
[ERROR]   CollectionDeserTest.testArrayIndexForExceptions:298 expected: <keys> but was: <>
[ERROR]   TestExceptionHandlingWithDefaultDeserialization.testShouldThrowExceptionWithPathReference:58 expected: <tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Foo["bar"]->tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Bar["baz"]> but was: <tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Foo["baz"]->tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Bar["baz"]>
[ERROR]   TypedArraySerTest.testListWithPolymorphic:87 expected: <{"beans":[{"@type":"bean","x":0}]}> but was: <{"beans":[{"@type":"bean"}]}>
[ERROR] Errors: 
[ERROR]   CurrentValueDeser4184Test.testCurrentValue4184EmptyPojo:92 » MismatchedInput currentValue() of wrong type, not User but: tools.jackson.databind.ser.filter.CurrentValueDeser4184Test$Role
 at [Source: (String)"{"role": {}, "type": {"value":1}}"; line: 1, column: 22] (through reference chain: tools.jackson.databind.ser.filter.CurrentValueDeser4184Test$User["type"])
[ERROR]   TestPOJOAsArray.testUnknownExtraProp:309 » MismatchedInput Unexpected token (`JsonToken.VALUE_FALSE`), expected `JsonToken.END_ARRAY`: Unexpected JSON values; expected at most 4 properties (in JSON Array)
 at [Source: (String)"{"value":[true,"Foobar",42,13, false]}"; line: 1, column: 32] (through reference chain: tools.jackson.databind.struct.TestPOJOAsArray$PojoAsArrayWrapper[""])

@cowtowncoder cowtowncoder changed the title Changed default of MapperFeature.DEFAULT_VIEW_INCLUSION to false in 3.0 Change default of MapperFeature.DEFAULT_VIEW_INCLUSION to false in 3.0 Jan 14, 2025
@cowtowncoder
Copy link
Member

Down to just 2 failures:

 Error:  Failures: 
Error:    CollectionDeserTest.testArrayIndexForExceptions:298 expected: <keys> but was: <>
Error:    TestExceptionHandlingWithDefaultDeserialization.testShouldThrowExceptionWithPathReference:58 expected: <tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Foo["bar"]->tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Bar["baz"]> but was: <tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Foo["baz"]->tools.jackson.databind.exc.TestExceptionHandlingWithDefaultDeserialization$Bar["baz"]>
[INFO] 
Error:  Tests run: 3484, Failures: 2, Errors: 0, Skipped: 0

cowtowncoder added a commit that referenced this issue Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 Issue planned for initial 3.0 release
Projects
None yet
Development

No branches or pull requests

3 participants