-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
2.15.0-rc1 regression: transient fields are serialized #3874
Comments
this is possibly because of
|
I think this is a side effect of some change related to pruning of First of all: note that the reason 2.14 and earlier did not include But there are at least 2 changes that should make things work in a way that'd work in both 2.15 and 2.14 (and earlier):
I suggest doing one of above; changes are behavior of 2.15 will remain the way rc2 has it (due to timing of things) so that is safer set up. |
Yeah, it would make sense that this would have changed if
Ok, I guess this was an unintentional "feature". Issue #296 appears to also deal with this. I'll admit I didn't look up whether Jackson promises anything about
So yeah, looks like this is a "regression" of a feature that was not promised. Thanks for the replies! |
@emlun Yes -- ideally behavior would not have changed, but it is bit of an edge case. I do consider it a regression but given how complicated the logic in that part is, it may be difficult to return handling of such cases. But I hope your use case works with some modifications. Thank you for follow up! |
Need to add @JsonIgnore too because transient + @JsonIgnore on the property does not work anymore in 2.15 See FasterXML/jackson-databind#3874 (comment) Before 2.15, it was an unexpected feature.
Need to add @JsonIgnore too because transient + @JsonIgnore on the property does not work anymore in 2.15 See FasterXML/jackson-databind#3874 (comment) Before 2.15, it was an unexpected feature.
Need to add @JsonIgnore too because transient + @JsonIgnore on the property does not work anymore in 2.15 See FasterXML/jackson-databind#3874 (comment) Before 2.15, it was an unexpected feature. (cherry picked from commit 867cb6b)
Need to add @JsonIgnore too because transient + @JsonIgnore on the property does not work anymore in 2.15 See FasterXML/jackson-databind#3874 (comment) Before 2.15, it was an unexpected feature. (cherry picked from commit 867cb6b)
Need to add @JsonIgnore too because transient + @JsonIgnore on the property does not work anymore in 2.15 See FasterXML/jackson-databind#3874 (comment) Before 2.15, it was an unexpected feature. (cherry picked from commit 867cb6b)
Describe the bug
In
2.14.2
and earlier,transient
fields (with or without@JsonIgnore
) with a getter (without@JsonIgnore
) are ignored during serialization and do not emit a JSON property.In
2.15.0-rc1
and2.15.0-rc2
, they do emit a JSON property.Example
Given this data class:
and this
ObjectMapper
:Jackson
2.14.2
serializes aFoo1
instance to{"a":0}
while Jackson2.15.0-rc1
serializes the same value to{"a":0,"minusA":0}
.Version information
Issue is not present in
2.14.2
.Issue is present in
2.15.0-rc1
.To Reproduce
jackson-regression-2-15-rc1
- might not persist after this issue is closed)../gradlew :test-success-2-14:test
. Observe that the test succeeds../gradlew :test-fail-2-15:test
. Observe that the test fails../gradlew :test-success-2-14:dependencies
. Observe that the resolved Jackson version is2.14.2
../gradlew :test-fail-2-15:dependencies
. Observe that the resolved Jackson version is2.15.0-rc1
.git diff --no-index lib/src/main/java/org/example/Foo1.java lib/src/main/java/org/example/Foo2.java
. Observe that the only (relevant) difference is thatFoo1.minusA
istransient
whileFoo2.minusA
is not.After running the above, you can see the failed test report at
test-fail-2-15/build/reports/tests/test/index.html
.Additional context
One might run into this when using Lombok's
@Value
annotation on classes withtransient
fields - even if the field has@JsonIgnore
, the generated getter does not inherit the@JsonIgnore
annotation.The text was updated successfully, but these errors were encountered: