Fix for #615: Use ValueInstantiators to rename creator properties so they match property definitions#806
Conversation
| // Second check: rename map from property definitions | ||
| String newName = renames.get(propName); | ||
| if (newName != null && !newName.equals(propName)) { | ||
| creatorProps[i] = prop.withSimpleName(newName); |
There was a problem hiding this comment.
Other than directly editing the array items, is there a better way to update the creator properties of the instantiator? I didn't see a setter.
There was a problem hiding this comment.
That does seem dangerous. Ideally would not tweak internal data structures nor have setters but create new instances.
I'll have to think about this one.
There was a problem hiding this comment.
I added a proposed improvement in the latest commit. This is safer but less performant, since we copy the array even if there is no need. Another option would be to only copy the array after we identify the first rename, but then we need to check if the array is not null each time that we rename.
There was a problem hiding this comment.
I think this is acceptable: this does not occur for every read but only when deserializer is constructed.
| // [dataformat-xml#423] | ||
| @JacksonTestFailureExpected | ||
| @Test | ||
| public void testXmlTextViaCtor423() throws Exception |
There was a problem hiding this comment.
This test started passing so I split it out so it could be removed from the tofix package.
There was a problem hiding this comment.
The test now resides in src/test/java/tools/jackson/dataformat/xml/deser/XmlTextViaCtor423Test.java
|
I see the build errors, let me take a look. |
8b1cbb5 to
c9b82bb
Compare
…ame creator properties so they match property definitions
|
Sorry about that. I somehow missed adding a module file to the commit. I've rebased and confirmed that everything is passing on my end. |
|
Additionally, since the rebase it looks like test #795 now also passes so I've also moved that one out of |
src/main/java/tools/jackson/dataformat/xml/deser/XmlValueInstantiators.java
Outdated
Show resolved
Hide resolved
src/main/java/tools/jackson/dataformat/xml/deser/XmlValueInstantiators.java
Outdated
Show resolved
Hide resolved
src/main/java/tools/jackson/dataformat/xml/JacksonXmlAnnotationIntrospector.java
Outdated
Show resolved
Hide resolved
Thank you! I found one more optimization I'd like to push. |
|
@mcvayc This looks very good -- thank you for contributing it! I'll add release notes and merge it for inclusion in 3.2.0! |
Ok I'll wait after updating release notes. |
Never mind, you beat me to it with your streamlining commit. :-) I was going to delay the array copy. |
Thank you for the kind words. It is good to get feedback like this. And thank you for providing the fixes here! |
Hi,
This PR was intended to fix #615 but in the process tests for #149, #517, #735, #795 in the
tofixpackage started passing as well. I've listed all the issues for which test are now passing in the commits, but still need to verify for those that the entire issue is fixed.The initial solution was co-written by Claude Code and me. After collaboratively creating a fix, I subsequently read through the code and edited it for quality and consistency. I believe the solution is now in decent shape, at least for #615.
Please let me know what you think. I'm happy to make further edits.