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

Getter naming leads to weird issues #980

Closed
snarayanank2 opened this issue Nov 30, 2015 · 3 comments
Closed

Getter naming leads to weird issues #980

snarayanank2 opened this issue Nov 30, 2015 · 3 comments

Comments

@snarayanank2
Copy link

Kudos to a great project! I've deleted 100s of lines of code :) Unfortunately, I had run into a weird problem once I incorporated Lombok.

The problem manifested itself when I was using Jackson to serialize POJOs to JSON. I had named my variable uId expecting it to show up as u_id in the resulting JSON. Turns out I was getting uid. This was breaking things. I initially filed an issue with Jackson which has a bunch of details.

After some investigation, it turned out that there was a subtle difference in the naming of the getter generated by Lombok which was the cause of all my trouble. My boilerplate getter generated by eclipse would generate a getter:

  public void getuId() { return uId; } 

Lombok was generating:

  public void getUId() { return uId; }

This naming caused difference in JSON serialization which caused all sorts of other problems. Looks like I was hit by the small print stuff noted here

I presume others would run into this as well. Any chance of changing this behavior or adding a flag to support this use case?

@henry1992007
Copy link

i encountered the same problem and used the default setter instead

@hao5ang
Copy link

hao5ang commented Nov 29, 2017

Same problem with XML. I manually ignore the lombok getter method to solve this.

I don't this this is one issue of lombok. It's the design issue of FasterXML.

@Getter
@Setter
pulbic class Pojo {
    @JsonProperty("UId")
    private String uId;
    
    @JsonIgnore
    public String getUId() {
        return uId;
    }
}

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 26, 2023

This was fixed in 1.18.24, it is now possible to set lombok.accessors.capitalization to change the behaviour. Related issue: #2693

@Rawi01 Rawi01 closed this as completed Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants