Skip to content

Unmapped field when the field name starts with 'set' and Lombok @Builder is used #36

Closed as not planned
@baltendo

Description

@baltendo

MapStruct Support: v1.1.1
MapStruct 1.3.0.Final
Lombok: 1.8.8
Java: openjdk version "11.0.2" 2019-01-15
Gradle: 5.4.1

We use MapStruct to map Java objects and Avro objects.
In one object there is one field that is not mapped from Avro to Java (the other way works).
This seems to be an issue only in Intellij because the test works when I run it with Gradle.

When I compare the generated ...MapperImpl.java from Intellij and Gradle I see that Intellij is using the .builder() from Lombok and Gradle uses the default constructor and then calls the setters (mapstruct/mapstruct#1742).

I think the issue is that the field starts with 'set' like 'settlement' which is already a known issue in MapStruct (mapstruct/mapstruct#1799). The Lombok builder just uses the field name as method name and MapStruct removes the 'set' so this ends up in 'tlement' which has no corresponding field in Avro. Because of that the generated ...MapperImpl.java never calls .settlement() on the builder.

Avro also generates a builder but it is prefixing the methods with 'set' (setSettlement) and thus it is not an issue mapping from Java to Avro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions