-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParameterNamesModule
does not deserialize with a single parameter constructor when using SnakeCase
PropertyNamingStrategy
#67
Comments
Is this something that passed in 2.9.1 but not in 2.9.2? Or between 2.8 and 2.9? Changes in general are not intentional, but due to complexity of auto-detection of mode between properties/delegating model, with possibly detection of implicit names for constructor argument, they may occur. Most likely change in behavior is due to a fix to another problem, but to know which issue, it's necessary to know version in which change occurred. As to work-around, I would recommend addition of explicit |
Yes. It passes in 2.9.1 but not in 2.9.2. I understand the single argument is complex, and adding the explicit mode declaration is an easy fix. I would recommend documenting this in 2.9.2 release notes though. If you update to 2.9.2, it is not immediately clear that the problem is with ParameterNamesModule. All I saw was that PropertyNamingStrategy.SNAKE_CASE was no longer working. Thanks for the quick response, and for all the work put into this excellent library! |
@sonnygill Just to make sure if it is not obvious: there is no intentional change that should break handling. If and when I figure out what is going on, a note would make sense. |
Exactly. We postponed upgrading from 2.9.1 for quite a while because it wasn't obvious what was breaking. This might help someone else in the same situation. To summarize, the issue happens when the following conditions are met:
The issue does not happen if any of the following conditions is true:
The workaround is of course to specify an explicit creatorBinding for ParameterNamesModule, for example,
|
Updated test.
|
I think this issue may have been reported before here, but wasn't recognised as a breaking change (that ticket was closed). |
I found another behavioural change from 3.9.1 to 3.9.2, so probably related to this. Add to the above test: private static class ClassWithTwoProperties {
public final int a;
public final int b;
private ClassWithTwoProperties(@JsonProperty("a") int a, @JsonProperty("b") int b) {
this.a = a;
this.b = b;
}
}
@Test
public void testPrivateConstructorWithPropertyAnnotations() throws Exception {
verifyObjectDeserializationWithNamingStrategy(PropertyNamingStrategy.SNAKE_CASE, "{\"a\":1, \"b\": 2}");
} This test passes in 3.9.1, but fails in 3.9.2 (to get it to pass in 3.9.2, I need to add an |
@scranen you probably mean |
Apologies, I do. Too many version upgrades today. |
@scranen I can not reproduce your issue; passes for me, for pre-2.9.6. Case is different as it has 2 parameters, |
@sonnygill I can reproduce this issue, and as you say, it will only occur if:
While I don't know exact details of why this causes problem, I think this is due to the fact that implicitly discovered creators must be handled at a later point, when more of discovery has occurred. Unfortunately it appears that naming-strategy induced renaming of properties happens before this point (but after explicitly found Creators). I suspect that the change itself is due to reordering of parts of processing, needed to fix some other issue. Usually one of fixed bugs in release notes would correlate to likely change but I do not see one here. It is possible this could be for a bug somewhere else (like Afterburner module), or, even due to unrelated refactoring (although less likely). Big problem, now, is that assuming I can locate the place of change, it is likely I can not just refer the change (if it fixed a problem). It is also possible that attempts at reordering processing cause other regressions. |
Also note related: FasterXML/jackson-databind#806 (in theory, even Plan is to rewrite Creator discovery process for 3.0 due to a few known issues. |
Sorry, forgot my project also uses different visibility settings. Added a full test script in this new ticket. |
@scranen thanks! |
For original issue, added test in FasterXML/jackson-databind#2008 which is probably somehow related. |
Ok. Found the root cause (or at least something to fix): FasterXML/jackson-databind#2051 and that seems to resolve the problem. |
ParameterNamesModule
does not deserialize with a single parameter constructor when using SnakeCase
PropertyNamingStrategy
Since release 2.9.2, the following test that passes with previous versions is broken.
The test passes with if I create the ParameterNamesModule with JsonCreator.Mode.PROPERTIES as the argument.
Is this intended? If so, this should probably be documented as a breaking change. Otherwise existing code bases break without warning.
It appears that the code responsible for this is BasicDeserializerFactory._addExplicitAnyCreator which was newly added in 2.9.2, but I am not certain.
Should I wait for a fix, or switch to using
new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)
? Can that have any side effects that I should watch out for?Thanks.
The text was updated successfully, but these errors were encountered: