Skip to content

Transient Fields are not ignored as Mutators if there is visible Getter #3682

@cowtowncoder

Description

@cowtowncoder

Looks like transient Fields are only ignored in cases if there is no explicit or just visible accessors, and as such Field like this:

public class Sizable {
    public transient int size; // lazily calculated

    public int getSize() {
        ...
    }
}

would actually try to use field size for setting value during deserialization. Without getSize() it would, however, be dropped despite being visible otherwise.
While this is not often problem with POJOs it is problematic with many JDK types (and probably some 3rd party libraries); and intent was never to "pull in" such Fields. It does, for example, break handling of LinkedList for JDK 17 and above, in cases where it (or sub-class) is to be serialized "as POJO".

So, for 2.15 let's prune these Fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions