Open precoder opened 4 days ago
I created a Unit Test to reproduce the issue (generation of json2 causes NPE). I made a quick fix by re-creating the JsonGenerator on resetAndGet call. If you can find a more fine granular solution without re-creating the JsonGenerator then you can get a better performance for JSON generation.
Hello everyone,
We have the oauth2authserver endpoints under: https://localhost:8843/auth/
If we call this endpoint on browser with GET call without any parameters, we land into DefaultEndpointProcessor and get {"error":"invalid_request"} as expected.
However on a second call with the same invalid request causes a NPE (stack trace enabled by <transport printStackTrace="true"/>):
Reason behind this is UTF8JsonGenerator uses a "_outputBuffer" array internally. This array is initialized in the Constructor. https://github.com/FasterXML/jackson-core/blob/jackson-core-2.17.2/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java#L131 or https://github.com/FasterXML/jackson-core/blob/jackson-core-2.17.2/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java#L164
This array is set to null by UTF8JsonGenerator ._releaseBuffers method after execution of the request. https://github.com/FasterXML/jackson-core/blob/jackson-core-2.17.2/src/main/java/com/fasterxml/jackson/core/json/UTF8JsonGenerator.java#L1277
on the next call for writeStartObject we get a NPE since the internal buffer is not re-initialized.