question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for @ConstructorProperties

See original GitHub issue

ConstructorProperties provide a standard way to communicate constructor properties. Currently, you have to use JsonCreator with JsonProperty to achieve the same behavior with jackson.

Libraries like lombok generate constructors using the standard annotation, which makes it necessary to manually annotate the constructor when using jackson. There are already libraries that add support for this annotation but I believe it could be added to the main project without problems.

I believe ConstructorProperties is absent on android so it might be necessary to handle that gracefully.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

6reactions
oliverlockwoodcommented, Nov 1, 2016

For anyone else who stumbles upon this - as a result of this change, on upgrading to Jackson 2.7, trying to deserialize a class which is

  • annotated with Lombok’s @AllArgsConstructor annotation, and
  • has a constructor annotated with @JsonCreator

I started having errors along the following lines:

com.fasterxml.jackson.databind.JsonMappingException: Conflicting property-based creators: already had explicitly marked [constructor for com.package.class, annotations: {interface java.beans.ConstructorProperties=@java.beans.ConstructorProperties(value=[all, my, instance, variables)}], encountered [constructor for com.package.class, annotations: {interface com.fasterxml.jackson.annotation.JsonCreator=@com.fasterxml.jackson.annotation.JsonCreator(mode=DEFAULT)}]

This is because under the covers Lombok’s constructors use the ConstructorProperties annotation by default. The problem can be fixed by setting the following value. lombok.anyConstructor.suppressConstructorProperties = true.

Hope that’s useful…

3reactions
ericxiongcommented, Dec 20, 2016

Any MapperFeature to disable using of ConstructorProperties ? AUTO_DETECT_CREATORS seems not working. @cowtowncoder

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add support for @ConstructorProperties · Issue #905 - GitHub
There are already libraries that add support for this annotation but I believe it could be added to the main project without problems....
Read more >
Don't understand @ConstructorProperties - Stack Overflow
So in the context of constructor properties, @ConstructorProperties({"someValue"}) means that the first parameter is associated with the getter ...
Read more >
Little-known yet useful Java annotation: ConstructorProperties
If I give this code to a colleague who doesn't have knowledge about Jackson and I ask them to add support for XML...
Read more >
[project lombok] @ConstructorProperties - Google Groups
add support for @ConstructorProperties to their compiler. I will post a comment on the GWT group to discuss this further. It would be...
Read more >
@NoArgsConstructor, @RequiredArgsConstructor ...
Overview. This set of 3 annotations generate a constructor that will accept 1 parameter for certain fields, and simply assigns this parameter to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found