-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Behavior of when FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL
enabled different after 2.12.0
#579
Comments
This is not enough to reproduce your issue: I'd need one to be able to help. So just a unit test that specifies exact calls (description has most of it but I am not sure how you get NPE) Note, too, that reproduction can not use other frameworks like Lombok: they need to be stand-alone. |
Also, wrong repo, transferred to |
No information to reproduce; may be re-opened/re-filed with test case |
|
@cowtowncoder Hi! I added test for my case. For jackson version < 2.12.0 test complete sucessfully, but for >=2.12.0 test is failed. |
@pavelturch Ok so do you expect
not but since 2.15 seems to produce non-null Object I am bit confused about this bug report (as test as written does not fail). Which versions have you tested? |
I'm expecting that testView is not null. I was tested it on 2.12.1, 2.12.7, 2.13.5, 2.14.3, 2.15.1 and I got null object in assertion. Runs under OpenJDK 1.8. My maven project have a parent "spring-boot-starter-parent 2.5.14" and I override jackson-bom.version property. I checked dependency conflicts and make sure that overrided version is used. What else can affect? |
I'll have to first try to reproduce this, but... I also think that from name |
Main problem in a root node. Nested empty nodes can be a null-obects. In my
case I got xml response from API that contains empty root node. Or another
case I need send empty xml root node, but body serializes to null.
вт, 23 мая 2023 г., 00:43 Tatu Saloranta ***@***.***>:
… I'll have to first try to reproduce this, but... I also think that from
name EMPTY_ELEMENT_AS_NULL it seems like it actually should produce null,
not an "empty" Object. Regardless of how Jackson 2.12.x behaved.
—
Reply to this email directly, view it on GitHub
<#579 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4FWZLQE5PT7K7BBZ4HNYLXHPMXFANCNFSM6AAAAAAVQOPFAQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@pavelturch I think I should re-phrase my question: do you really need to want to enable |
@cowtowncoder I really need a backward compatibility for our API :) And yes, I want to enable EMPTY_ELEMENT_AS_NULL. |
Ok. Realistically speaking if all versions since 2.12.1 return Looking at release notes, I think #435 is the fix that changed behavior. NOTE: one possibility for supporting alternate behavior while retaining compatibility is to add more Feature choices. This is a possibility to separate handling at root value level. |
FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL
enabled different after 2.12.0
Ok. I understand, thank you. Here is another case with mapper.enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL). `
` |
Yes, in general with this setting any and all empty XML elements ( That said I think it's not a great feature, partly as in XML there is no semantic distinction between But for what it is worth I don't think behavior wrt root element will be changed at this point. |
Ok: this works as intended. I added a test to verify the behavior as sort of documentation. |
@cowtowncoder Ok, thanks |
@lazyr1ch no problem & apologies for the mess we got here. I don't like introducing backwards-incompatible changes like this. Thank you for your understanding. |
I have a class
and enabled feature FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL for XmlMapper.
Then i trying to call
FooView fooView = xmlMapper.readValue(content, FooView.class)
and set content as:
<Content/>
As result i've had a NP:
java.lang.NullPointerException: Cannot invoke method getStr() on null object
Before 2.12.0 returned result object (fooView) was not null object.
Version information
2.12.1 and greater. 2.12.0 gets another bug too.
The text was updated successfully, but these errors were encountered: