-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
When the localName
property of @JacksonXmlProperty
is not set, the required
of @JsonProperty
does not detect the property name of POJO
#628
Comments
Ok the problem here is, I think, that for naming purposes I think this should be fixable, but has to be done in |
Actually, I take that back: constructor parameters' names are only discovered if using
Does not have name available: either |
org.opentest4j.AssertionFailedError: Unexpected exception thrown: com.fasterxml.jackson.databind.exc.MismatchedInputException: Missing required creator property '' (index 0)
at [Source: (StringReader); line: 4, column: 1] (through reference chain: com.lingh.RequiredTest$TestRecordWithoutLocalName[""]) |
@linghengqian Ok. In that case, that's problematic. I'll need to figure out if Parameter names module (or something in. Jackson databind) needs improvement -- ideally missing/empty local name should not override "implicit" name brought in by module. I do have a related fix to make, via FasterXML/jackson-databind#4364 but not sure that is enough. EDIT: now both fixes are in so test case might have a chance to work -- but I have not tested full set up yet (test needs to be in EDIT 2: tested against |
@linghengqian If you have a way to test against |
sdk install java 21.0.2-graalce
sdk use java 21.0.2-graalce
git clone [email protected]:FasterXML/jackson-dataformat-xml.git -b 2.17
cd ./jackson-dataformat-xml/
git reset --hard 9f1aa0f5054a7a75acfc8155df9aee50059fb5da
./mvnw clean install -T1C -DskipTests
cd ../
git clone [email protected]:FasterXML/jackson-modules-java8.git -b 2.17
cd ./jackson-modules-java8/
git reset --hard 1876ea82f326e05757d2a439af2b56290bb5d7c3
./mvnw clean install -T1C -DskipTests
cd ../
git clone [email protected]:linghengqian/jackson-mixed-annotations-test.git
cd ./jackson-mixed-annotations-test/
./mvnw clean test
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Missing required creator property '' (index 0)
at [Source: (StringReader); line: 4, column: 1] (through reference chain: com.lingh.RequiredTest$TestRecordWithoutLocalName[""])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1781)
at com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer._findMissing(PropertyValueBuffer.java:192)
at com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer.getParameters(PropertyValueBuffer.java:158)
at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromObjectWith(ValueInstantiator.java:301)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:202)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:526)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1493)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:348)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.dataformat.xml.deser.XmlDeserializationContext.readRootValue(XmlDeserializationContext.java:104)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4905)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3848)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3816)
at com.lingh.RequiredTest.lambda$assertRequiredValue$1(RequiredTest.java:28)
at org.junit.jupiter.api.AssertDoesNotThrow.assertDoesNotThrow(AssertDoesNotThrow.java:49)
... 6 more
|
That sounds like problem still persists: I can reproduce this with your project as well. Odd part is that it really looks as if |
Ok. I think I know the problem: project settings are such that javac will not actually include method/constructor parameter names in bytecode -- and as such ParameterNamesModule cannot find any. I can make test pass by adding this in
|
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
|
@linghengqian Yes, let's close this issue. |
TL;
localName
property of@JacksonXmlProperty
is not set, therequired
of@JsonProperty
does not detect the property name of POJO.localName
attribute of@JacksonXmlProperty
has the same function as https://github.com/FasterXML/jackson-annotations?tab=readme-ov-file#annotations-for-renaming-properties , but is used renaming of POJO properties. Not settinglocalName
should not cause this error.The text was updated successfully, but these errors were encountered: