Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
(Java) V4 4.7.1
-
None
Description
2022-07-15T11:05:15,678 WARN [mock-1] header.ODataErrorResponseChecker:76 Error deserializing error response java.lang.NullPointerException: null at org.apache.olingo.client.core.serialization.JsonODataErrorDeserializer.doDeserialize(JsonODataErrorDeserializer.java:46) ~[odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.serialization.JsonDeserializer.toError(JsonDeserializer.java:442) ~[odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl.toError(ClientODataDeserializerImpl.java:105) ~[odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.serialization.ODataReaderImpl.readError(ODataReaderImpl.java:86) ~[odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker.checkResponse(ODataErrorResponseChecker.java:64) [odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.communication.request.AbstractRequest.checkResponse(AbstractRequest.java:58) [odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.communication.request.AbstractODataRequest.doExecute(AbstractODataRequest.java:316) [odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl.execute(ODataEntitySetRequestImpl.java:61) [odata-client-core-4.7.1.jar:?] at org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl.execute(ODataEntitySetRequestImpl.java:39) [odata-client-core-4.7.1.jar:?] at ...
[org.apache.olingo.client.api.communication.ODataClientErrorException: (401) Unauthorized [HTTP/1.1 401 Unauthorized]], oDataError {"code":"401","message":"Unauthorized","target":null,"details":null,"innerError":null}
Offending line in org.apache.olingo.client.core.serialization.JsonODataErrorDeserializer.doDeserialize(JsonParser)
is
if (tree.has(Constants.JSON_ERROR)) {
in
protected ODataError doDeserialize(final JsonParser parser) throws IOException { final ODataError error = new ODataError(); final ObjectNode tree = parser.getCodec().readTree(parser); if (tree.has(Constants.JSON_ERROR)) { final JsonNode errorNode = tree.get(Constants.JSON_ERROR);
so apparently readTree() returns null (which should valid).
Here
org.apache.olingo.client.core.communication.request.AbstractRequest.checkResponse(ODataClient, HttpResponse, String)
protected void checkResponse( final ODataClient odataClient, final HttpResponse response, final String accept) { if (response.getStatusLine().getStatusCode() >= 400) { Header contentTypeHeader = response.getEntity() != null ? response.getEntity().getContentType() : null; try { final ODataRuntimeException exception = ODataErrorResponseChecker.checkResponse( odataClient, response.getStatusLine(), response.getEntity() == null ? null : response.getEntity().getContent(), (contentTypeHeader != null && contentTypeHeader.getValue().contains(TEXT_CONTENT_TYPE)) ? TEXT_CONTENT_TYPE : accept);
org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker.checkResponse(ODataClient, StatusLine, InputStream, String)
guesses to content type to be JSON and then
JsonODataErrorDeserializer
simply stumbles over an empty body (my assumption).
Going by the current source code 4.10 would also be affected (unless anything in the caller would have changed).
https://github.com/apache/olingo-odata4/blob/master/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/JsonODataErrorDeserializer.java
Attachments
Issue Links
- links to