On Mon, Apr 16, 2018 at 6:40 AM, Ondra Žižka <dynaw...@gmail.com> wrote:
> Hi, we use Lombok and Jackson. Our DTOs have a bit weird setup:
>
> class SomeDTO {
>     @JsonIgnore
>     private int id;
>
>     @JsonProperty("id")
>     private int uid;
> }
>
> DropWizard 1.3.1 needs jackson-databind (otherwise throws
> NoClassDefException), so I have added it.
> After upgrading Jackson to 2.9.5 (which Dw uses), Jackson (since 2.9.2)
> started to fail to load the models when creating the ObjectMapper,
> complaining about duplicate property "id".
>
> com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
> Duplicate creator property "id" (index 0 vs 1)
>  at [Source: (String)"{
>   "description": "patched description"}"; line: 1, column: 1]
>         at com.fasterxml.jackson.databind.exc.InvalidDefinitionExc
>
>
>
> This is because we use Lombok's @Builder, which needs @AllArgsConstructor,
> and Jackson started to take this constructor into account as JSON creator I
> assume.
>
> The only way to fix it I have found was to get rid of the @Builder and
> @AllArgsConstructor. That way, Jackson works fine.
>
> I don't know how Jackson internally works. Is there some option or
> workaround I could use to get over that duplicated id issue?

Hmmh. This does sound like a potential flaw in Creator
property/parameter handling.
Problem is that discovery and handling of Creator properties is
something separate from discovery of
"regular" properties, and reconciliation of these sets is quite tricky
(on 2.x; hoping to rewrite all of it for 3.x).
So what may happen is that there is discrepancy.

What would help is filing a new issue if it is possible to demonstrate
this with class as seen by Jackson
after Lombok processing. This should be relatively simple case, I
hope, as you have nicely created minimal
reproduction (for Lombok context). It seems like normal pruning of
properties did not work, or, possibly,
unification of separate accessors did not (since "implicit" names,
"id" vs "uid" differ).
The important piece to see is the constructor declaration along with
annotations.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to