GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BUG] Transient properties in classes with @Jacksonized @Accessors(fluent=true) get serialized · Issue #3936 · projectlombok/lombok

[BUG] Transient properties in classes with @Jacksonized @Accessors(fluent=true) get serialized #3936

New issue
Copy link
New issue
Copy link
Closed
Closed
[BUG] Transient properties in classes with @Jacksonized @Accessors(fluent=true) get serialized#3936
Copy link
Milestone
v1.18.44

Description

@renedewaele
renedewaele
opened on Sep 10, 2025
Issue body actions

Describe the bug
When creating a class with @Accessors(fluent = true) and @Jacksonized that contains transient fields, they inadvertently get serialized since v1.18.40.

To Reproduce
Class:

@Value
@Builder
@Jacksonized
@Accessors(fluent = true)
public class Foo {
    String foo;
    transient String transientFoo;
}

results in:

@JsonDeserialize(
    builder = FooBuilder.class
)
public final class Foo {
    @JsonProperty("foo")
    private final String foo;
    @JsonProperty("transientFoo")
    private final transient String transientFoo;

    ...
}

Expected behavior
Transient fields should not get @JsonProperty.

Version info (please complete the following information):
Since v1.18.40 on all platforms

Additional context
Probably caused by: #3860

Activity

  1. renedewaele
    added a commit that references this issue on Sep 10, 2025

    chore(dependencies): update multiple dependencies and plugins to late…

    ef0e933
  2. janrieke commented on Sep 10, 2025

    @janrieke
    janrieke
    on Sep 10, 2025
    Contributor
    More actions

    Yeah, @JsonProperty takes precedence over transient. I have not thought about that.

    Workaround for the time being is probably putting @JsonIgnore on the field. According to this issue, newer Jackson version should ignore it in this case (but I did not test it).
    If that does not work, you could implement the getter manually.

  3. renedewaele commented on Sep 10, 2025

    @renedewaele
    renedewaele
    on Sep 10, 2025
    Author
    More actions

    Hi @janrieke, indeed. I was already using that workaround ;).

  4. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    Just to make sure I am understanding this right, the expected output of this:

    @Value
    @Builder
    @Jacksonized
    @Accessors(fluent = true)
    public class Foo {
        String foo;
        transient String transientFoo;
    }

    would be the following?

    public final class Foo {
        @JsonProperty("foo")
        private final String foo;
        @JsonIgnore
        private final transient String transientFoo;
    
        ...
    }
  5. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    When creating a class with @Accessors(fluent = true) and @Jacksonized that contains transient fields, they inadvertently get serialized since v1.18.40.

    Is this bug specific to when both @Accessors and @Jacksonized is used?
    Or is it a general issue where @Jacksonized disregards transient values?

  6. janrieke commented on Sep 18, 2025

    @janrieke
    janrieke
    on Sep 18, 2025
    Contributor
    More actions

    A @Jacksonized @Builder also does not ignore transient fields, but that doesn't hurt in most cases, because the field won't be in the payload to be deserialized.
    What's new in 1.18.40 is that @Jacksonized @Accessors puts @JsonProperty on all fluent accessors, so suddenly also transient fields are included in the serialization in this case. Lombok should simply not put that annotation on a transient field's accessors (adding a @JsonIgnore is not necessary).

    Reacted by René de Waele
  7. renedewaele commented on Sep 18, 2025

    @renedewaele
    renedewaele
    on Sep 18, 2025
    Author
    More actions

    Thanks @liampace and @janrieke for looking into this.

    @janrieke is right. I only just realized that I’ve been serializing some transient fields all these years :). For some reason I assumed that transient fields in data objects wouldn’t be serialized. But since getters are generated for those fields too, that assumption never really made sense.

    As @janrieke also pointed out, it hasn’t caused too many problems for me before because the transient properties were ignored during deserialization.

    This has definitely been a wake-up call for me as well. Even after this is fixed, I’ll still keep @JsonIgnore for this reason.

    Keep up the good work!

  8. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    I'm working on implementing a PR for this issue, which will automatically add @JsonIgnore to transient values.

    However, would it, a) be a good idea, and b) make sense, to add an override feature like ToString.Include or ToString.Exclude for @Jacksonized as well?

    For example:

    @Value
    @Builder
    @Jacksonized
    @Accessors(fluent = true)
    public class Foo {
        @Jacksonized.Exclude String foo;
        @Jacksonized.Include transient String transientFoo;
    }

    would generate the following:

    public final class Foo {
        @JsonIgnore
        private final String foo;
        @JsonProperty("transientFoo")
        private final transient String transientFoo;
        ...
    }
  9. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    ...(adding a @JsonIgnore is not necessary).

    It seems that this is not the case, due to the fact that Jackson relies on getters/setters to determine serializable fields. I think Lombok should automatically add @JsonIgnore to transient fields

  10. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    However, would it, a) be a good idea, and b) make sense, to add an override feature like ToString.Include or ToString.Exclude for @Jacksonized as well?

    Having thought about this for a little bit more, I don't think such a feature would make sense as the whole point of transient is to declare that a field shouldn't be serialized/de-serialized.

    On another note, are there any popular annotations that mimic the transient keyword that @Jacksonized should support? I want to make sure that as many bases are covered before submitting the PR.

  11. janrieke commented on Sep 18, 2025

    @janrieke
    janrieke
    on Sep 18, 2025
    Contributor
    More actions

    @JsonIgnore is not necessary because Jackson does not recognize fluent accessors in the first place.

  12. liampace commented on Sep 18, 2025

    @liampace
    liampace
    on Sep 18, 2025
    Contributor
    More actions

    Ok, thank you for the clarification.

    However, I think it is better to be explicit about this because the implicit behavior of Jackson can always change.

    Anyways, I've created a pull request for this bug

  13. renedewaele commented on Sep 19, 2025

    @renedewaele
    renedewaele
    on Sep 19, 2025
    Author
    More actions

    @JsonIgnore is not necessary because Jackson does not recognize fluent accessors in the first place.

    I was thinking of other classes with transient fields that do not have fluent accessors.

    @liampace There are some @Transient annotations in the wild too, but I don't think it's always correct to place @JsonIgnore on the getter in those cases.

  14. janrieke commented on Sep 29, 2025

    @janrieke
    janrieke
    on Sep 29, 2025
    Contributor
    More actions

    However, I think it is better to be explicit about this because the implicit behavior of Jackson can always change.

    Yeah, let's play it safe here. We never know what happens in future Jackson versions, especially with Jackson 3 coming up.

  15. rzwitserloot commented on Jan 29, 2026

    @rzwitserloot
    rzwitserloot
    on Jan 29, 2026
    Collaborator
    More actions

    Agree with it all:

    Liam Pace wrote:

    However, would it, a) be a good idea, and b) make sense, to add an override feature like ToString.Include or ToString.Exclude for @Jacksonized as well?

    Agree with your later assessment: Once you slap transient on a field, you made your bed. Not a good idea.

    Jan Rieke wrote:

    Yeah, let's play it safe here. We never know what happens in future Jackson versions, especially with Jackson 3 coming up.

    Hopefully no lint tools are around that generate a warning due to a superfluous @JsonIgnore annotation. But I bet there aren't any - agreed. Conveniently that means Liam's PR should match desired behaviour to a 'T' :)

  16. rzwitserloot commented on Jan 29, 2026

    @rzwitserloot
    rzwitserloot
    on Jan 29, 2026
    Collaborator
    More actions

    PR accepted (in a way that github doesn't appear to understand). Thanks @liampace and @janrieke !

  17. rzwitserloot
    closed this as completedon Jan 29, 2026
  18. rzwitserloot
    added this to the next-version milestone on Jan 29, 2026
  19. rzwitserloot
    added 2 commits that reference this issue on Jan 29, 2026

    [changelog] document #3936: `@Jacksonized`+`transient` now more consi…

    bff559f

    [changelog] document #3936: `@Jacksonized`+`transient` now more consi…

    d398ad6
  20. dongjoon-hyun
    added a commit that references this issue on Mar 25, 2026

    [SPARK-56194] Upgrade `Lombok` to 1.18.44

    864f58d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • v1.18.44

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.