Quick revision
The short answer
For a primitive boolean field named isPublished, Lombok generates isPublished() and setPublished(boolean), following the JavaBeans rule that drops the "is" from the property name. Jackson derives property names from those accessors, so it sees a property called published: it writes "published" and ignores an incoming "isPublished". The robust fix is to rename the field to published and annotate it @JsonProperty("isPublished") if the JSON contract needs that name, or simply to use "published" in the contract.
What to remember
In this answer, we saw that Lombok generates isPublished() and setPublished() for a primitive boolean field named isPublished, so Jackson derives the property name published, writes it and ignores incoming isPublished. We fixed it by renaming the field to published and annotating it @JsonProperty("isPublished") where the contract needs that name, explained why annotating the old field alone depends on what Lombok copies to accessors, noted that a wrapper Boolean gives getIsPublished() and a different JSON name, and pinned the shape with a contract test.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
For a primitive boolean field named isPublished, Lombok generates isPublished() and setPublished(boolean), following the JavaBeans rule that drops the "is" from the property name. Jackson derives property names from those accessors, so it sees a property called published: it writes "published" and ignores an incoming "isPublished". The robust fix is to rename the field to published and annotate it @JsonProperty("isPublished") if the JSON contract needs that name, or simply to use "published" in the contract.
Why this question is asked
Boolean naming is one of the small things that cause real API bugs: a client sends a field, the server silently ignores it, and an article is never published, with no error anywhere. Interviewers ask this debugging question because it sits exactly where three sets of rules meet: the JavaBeans naming convention, Lombok's accessor generation and Jackson's property detection. In this answer, we will recap how Jackson finds property names, see what Lombok generates for this field, reproduce both symptoms, go through the fixes, and see why wrapper Booleans behave differently again.
1A Quick Recap: How Jackson Finds Property Names
Jackson does not look at field names first. By default, it builds its list of properties from the accessor methods, following the JavaBeans convention: a getter getTitle() means a property title, a setter setTitle(...) means the same property, and for booleans a getter isDraft() also means a property draft. Fields are used too, but a private field without an annotation only helps when it can be linked to an accessor with the same property name.
So the name in the JSON is whatever name Jackson derives from the methods. If the methods are generated by Lombok, the JSON shape depends on what Lombok generates.
2What Lombok Generates for boolean isPublished
Lombok has a special rule for primitive boolean fields whose names start with "is" followed by a capital letter. It does not generate isIsPublished(); it uses the field name itself as the getter name, and for the setter it drops the "is".
| Field | Lombok getter | Lombok setter | Jackson property |
|---|---|---|---|
| boolean published | isPublished() | setPublished() | published |
boolean isPublished | isPublished() | setPublished() | published |
| Boolean published | getPublished() | setPublished() | published |
Boolean isPublished | getIsPublished() | setIsPublished() | isPublished |
Notice that both accessors point to the property published. From Jackson's point of view, the class has properties title and published. The field's own name, isPublished, does not match any accessor's property name, so it plays no part.
3Reproducing Both Symptoms
With the class above, we write an object and read a request body.
The read is silent because Spring Boot's ObjectMapper does not fail on unknown properties. With a plain ObjectMapper, the default would raise UnrecognizedPropertyException, which at least makes the problem visible.
4Fix 1: Rename the Field and State the JSON Name
The robust fix is to name the field the way the JavaBeans convention expects, published, and, if the JSON contract must keep isPublished, to say so with @JsonProperty on the field.
Now the field, the getter and the setter all have the same internal property name, published, so Jackson links them into one property, and the annotation on the field renames that whole property to isPublished. The Java API, isPublished() and setPublished(), reads naturally, and the JSON matches the contract.
5Why Annotating the Old Field Alone Is Fragile
It is tempting to keep the field as isPublished and only add @JsonProperty("isPublished") to it. The field then has the internal name isPublished while the accessors have the internal name published, so Jackson may treat them as two different properties and write both names, unless the annotation also reaches the generated accessors. Recent Lombok versions copy @JsonProperty from the field to generated setters (and the list of copied annotations can be extended with lombok.copyableAnnotations), but what exactly is copied to which accessor depends on your version, so check it.
Renaming the field removes the question: one internal name, one property, one explicit JSON name. During a migration, @JsonAlias("published") on the field can accept both spellings in requests while clients move over.
6The Wrapper Boolean Case, and a Contract Test
If the field is a wrapper Boolean, Lombok does not apply the "is" rule. It generates getIsPublished() and setIsPublished(), so Jackson sees a property called isPublished. Changing the type from boolean to Boolean therefore changes the JSON name, which is a nasty surprise in a refactoring. The team should pick one convention, for example adjective names without "is" for all boolean fields, and apply it everywhere.
Because none of this is visible in the source, a contract test should pin the JSON shape of each public DTO.
- Collect accessors
isX(),getX(),setX()give the internal name x - Collect fieldsa field's internal name is its own name
- Group by internal namesame name -> one property
- Apply @JsonPropertyrenames the whole group
- Write or match JSONunmatched input is ignored or rejected
5 steps in order. Play them, or step through them one at a time.
7Follow-up questions
Why does Lombok drop the is prefix in the setter?
It follows the JavaBeans convention, in which a boolean property named published has accessors isPublished() and setPublished(). Lombok assumes the field isPublished really means the property published, so it generates the accessors for that property. That is reasonable for Java callers, but it changes the JSON name.
Would a record avoid this?
Mostly, yes. A record ArticleDto(String title, boolean isPublished) has an accessor called isPublished() that Jackson's record support maps to the component name, so the JSON property is isPublished. It is still worth a contract test, because behaviour around is-prefixed names has changed between Jackson versions.
Should the server reject unknown properties?
For public APIs it is a trade-off. Rejecting catches mistakes like this one immediately, but makes adding fields harder for clients. Many teams accept unknown properties but test the contract, as above.
8Conclusion
In this answer, we saw that Lombok generates isPublished() and setPublished() for a primitive boolean field named isPublished, so Jackson derives the property name published, writes it and ignores incoming isPublished. We fixed it by renaming the field to published and annotating it @JsonProperty("isPublished") where the contract needs that name, explained why annotating the old field alone depends on what Lombok copies to accessors, noted that a wrapper Boolean gives getIsPublished() and a different JSON name, and pinned the shape with a contract test.
Open with
Jackson builds property names from accessors, following the JavaBeans convention. For a primitive boolean field named isPublished, Lombok does not generate isIsPublished; it uses isPublished() as the getter and drops the is for the setter, setPublished.
Then, if they want more
Both accessors mean the property published, so Jackson writes published, and an incoming isPublished matches nothing. Spring Boot's ObjectMapper ignores unknown properties, so the value is silently lost. The fix I prefer is to rename the field to published, which is what the convention expects, and if the API contract must say isPublished, put @JsonProperty("isPublished") on the field.
Then field, getter and setter share one internal name and the annotation renames the whole property. Just annotating the old isPublished field is fragile, because the field and the accessors have different internal names and Jackson may produce both, depending on whether Lombok copies the annotation to the generated accessors in our version.
I would also point out that a wrapper Boolean behaves differently: Lombok generates getIsPublished, so the JSON name becomes isPublished, meaning a type change silently changes the contract. So the team should pick one convention for boolean names, and add contract tests that serialise and deserialise each public DTO against the expected JSON.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A DTO has a field private boolean isPublished with @Data. The JSON output contains...": https://scrivio-interview-library.netlify.app/java/lombok/72372fd14b/