{"action":"created","issue":{"url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1708","repository_url":"https://api.github.com/repos/rzwitserloot/lombok","labels_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1708/labels{/name}","comments_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1708/comments","events_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1708/events","html_url":"https://github.com/rzwitserloot/lombok/issues/1708","id":327531949,"node_id":"MDU6SXNzdWUzMjc1MzE5NDk=","number":1708,"title":"extraPrivate=true from 1.16.22 breaks Jackson creator detection","user":{"login":"bcalmac","id":3707379,"node_id":"MDQ6VXNlcjM3MDczNzk=","avatar_url":"https://avatars2.githubusercontent.com/u/3707379?v=4","gravatar_id":"","url":"https://api.github.com/users/bcalmac","html_url":"https://github.com/bcalmac","followers_url":"https://api.github.com/users/bcalmac/followers","following_url":"https://api.github.com/users/bcalmac/following{/other_user}","gists_url":"https://api.github.com/users/bcalmac/gists{/gist_id}","starred_url":"https://api.github.com/users/bcalmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcalmac/subscriptions","organizations_url":"https://api.github.com/users/bcalmac/orgs","repos_url":"https://api.github.com/users/bcalmac/repos","events_url":"https://api.github.com/users/bcalmac/events{/privacy}","received_events_url":"https://api.github.com/users/bcalmac/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2018-05-30T00:28:50Z","updated_at":"2018-06-04T21:30:21Z","closed_at":null,"author_association":"NONE","body":"In our project I use value objects like the one below. The only addition to a vanilla `@Value` + `@Builder` is overriding the all-args constructor so that I initialize the fields to a default value irrespective of how the object is built: through the all-args constructor (Jackson deserialization) or the builder (my code)\r\n\r\n```java\r\n@Value\r\n@Builder\r\npublic class Subscription {\r\n\r\n    String organizationKey;\r\n    String productKey;\r\n    boolean enabled;\r\n    Throttling throttling;\r\n    ImmutableList<Endpoint> endpoints;\r\n    ImmutableList<Constraint> constraints;\r\n\r\n    private Subscription(String organizationKey, String productKey, Boolean enabled, Throttling throttling,\r\n            ImmutableList<Endpoint> endpoints, ImmutableList<Constraint> constraints) {\r\n\r\n        this.organizationKey = organizationKey;\r\n        this.productKey = productKey;\r\n        this.enabled = defaultIfNull(enabled, TRUE);\r\n        this.throttling = throttling;\r\n        this.endpoints = defaultIfNull(endpoints, ImmutableList.of());\r\n        this.constraints = defaultIfNull(constraints, ImmutableList.of());\r\n    }\r\n}\r\n```\r\n\r\nThis worked fine prior to 1.16.22, Jackson automatically detects the constructor as `@JsonCreator` and invokes it with all known properties and `null` for the rest. It also looks nice, the class has no Jackson annotations.\r\n\r\nHowever, after the private no-args constructor added in 1.16.22, Jackson will by default instantiate the object using the no-args constructor and then set the individual fields one by one. Without the all-args constructor, my defaults will no longer be enforced.\r\n\r\nThis can be fixed by explicitly adding the `@JsonCreator` to the all-args constructor. Leaving aside the extra annotation that's needed now, this sneaky change will silently break a lot of code that relies on an explicit constructor.\r\n\r\nPlease evaluate the \"noArgsConstructor.extraPrivate\" new feature against side-effects like the one mentioned here. Jackson was working fine for me without any extra annotation. What is the \"killer use-case\" for the new feature?\r\n\r\nAlso, `@Builder.Default` would NOT work with Jackson deserialization (before or after this change).\r\n\r\n```java\r\n    @Builder.Default\r\n    ImmutableList<Constraint> constraints = ImmutableList.of();\r\n```"},"comment":{"url":"https://api.github.com/repos/rzwitserloot/lombok/issues/comments/394506170","html_url":"https://github.com/rzwitserloot/lombok/issues/1708#issuecomment-394506170","issue_url":"https://api.github.com/repos/rzwitserloot/lombok/issues/1708","id":394506170,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDUwNjE3MA==","user":{"login":"bcalmac","id":3707379,"node_id":"MDQ6VXNlcjM3MDczNzk=","avatar_url":"https://avatars2.githubusercontent.com/u/3707379?v=4","gravatar_id":"","url":"https://api.github.com/users/bcalmac","html_url":"https://github.com/bcalmac","followers_url":"https://api.github.com/users/bcalmac/followers","following_url":"https://api.github.com/users/bcalmac/following{/other_user}","gists_url":"https://api.github.com/users/bcalmac/gists{/gist_id}","starred_url":"https://api.github.com/users/bcalmac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcalmac/subscriptions","organizations_url":"https://api.github.com/users/bcalmac/orgs","repos_url":"https://api.github.com/users/bcalmac/repos","events_url":"https://api.github.com/users/bcalmac/events{/privacy}","received_events_url":"https://api.github.com/users/bcalmac/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T21:30:21Z","updated_at":"2018-06-04T21:30:21Z","author_association":"NONE","body":"@rspilker, thank you for chiming in. Isn't jackson-module-parameter-names an adequate alternative to `@ConstructorProperties`? \r\n\r\nFrom what I understand, this is a Jackson / Java 9 issue, I wouldn't expect Lombok to automatically fix it for me. Different projects would probably what to go with different solutions. IMHO Lombok should stay true to what a `@Value` is, and that does not include a no-args constructor. By getting in the middle of this, Lombok stops being a helper for generating boilerplate code and starts prescribing how objects should be designed.\r\n\r\nNow, if this feature is here to stay, how would you reconcile it with the statement below? It's a guarantee that once you step in by defining a constructor, Lombok gets out of the way.\r\n\r\n> Also, any **explicit constructor**, no matter the arguments list, implies **lombok will not generate a constructor**. If you do want lombok to generate the all-args constructor, add AllArgsConstructor to the class. You can mark any constructor or method with @lombok.experimental.Tolerate to hide them from lombok.\r\n\r\n"}}
{"actor":{"display_login":"bcalmac"}}