NullPointerException fix
in com.fasterxml.jackson.databind.ext.CoreXMLSerializers the visitor is passed with a null as JavaType. Because of this a NPE could be thrown in TSJsonFormatVisotorWrapper.expectStringFormat(null)
@schurik, both Your commits contain lots of formatting changes that every other developer might want to reformat according to their preferences. Could undo the formatting changes?
I'm also wondering in which situation that NPE reveals itslef. There are lots of tests for jackson module, probably I've missed smth.
@atsu85 I will undo the formatting changes. I am using XMLGregorianCalender in my model. Inside the CoreXMLSerialie.acceptJsonFormatVisitor method the visitor and null is passed to the delegate. And in case TSJsonFormatVisitorWrapper.expectStringFormat() the type is null. Here the NPE occurs
@schurik, thanks for undoing the formatting changes.
I tried to quickly reproduce the issue this PR should address, but i probably tried smth different, as everything seemed to work well, when I added
public XMLGregorianCalendar _XMLGregorianCalendar;
to DefinitionGeneratorTest.TestClass, the output included the field with number type that seems to be expected:
export interface TestClass {
_XMLGregorianCalendar: number;
// other fields and methods
}
What did You do differently? Perhaps You could even create/update the test for this issue Yourself?
In my case my model needs to be serialized as JSON and/or XML. My property has an addition @JsonFormat anntotation.
This is my setup:
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.sss'Z'", timezone = "GMT") public XMLGregorianCalendar _someDate;
and the output is:
export interface TestClass { _XMLGregorianCalendar: string; }
and while serializing _someDate I get NPE without the null check
@schurik, thanks, I'll add the test myself. Could You also squash the commits into single commit?
Hi @schurik, I had pretty-much forgotten this after failing to reproduce the NPE You reported and tried to fix with this PR. Please see my comments from the commit that tries to create the test for reproducing the NPE.
Please help me to figure out how to reproduce this issue, so the test could be updated and i could merge the fix.