You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "mibo (Jira)" <ji...@apache.org> on 2022/11/12 21:35:00 UTC

[jira] [Resolved] (OLINGO-1577) NullPointerException in JsonODataErrorDeserializer (on empty response body?)

     [ https://issues.apache.org/jira/browse/OLINGO-1577?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

mibo resolved OLINGO-1577.
--------------------------
    Resolution: Fixed

> NullPointerException in JsonODataErrorDeserializer (on empty response body?)
> ----------------------------------------------------------------------------
>
>                 Key: OLINGO-1577
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1577
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata4-client
>    Affects Versions: (Java) V4 4.7.1
>            Reporter: Florian Kolbe
>            Assignee: mibo
>            Priority: Major
>             Fix For: (Java) V4 4.10.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> {noformat}
> 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
> ...
> {noformat}
> {noformat}
> [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}
> {noformat}
> Offending line in org.apache.olingo.client.core.serialization.JsonODataErrorDeserializer.doDeserialize(JsonParser)
> is
> {noformat}
> if (tree.has(Constants.JSON_ERROR)) {
> {noformat}
> in
> {noformat}
>   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);
> {noformat}
> so apparently readTree() returns null (which should valid).
> Here
> {noformat}
> org.apache.olingo.client.core.communication.request.AbstractRequest.checkResponse(ODataClient, HttpResponse, String)
> {noformat}
> {noformat}
>   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);
> {noformat}
> {noformat}
> org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker.checkResponse(ODataClient, StatusLine, InputStream, String)
> {noformat}
> guesses to content type to be JSON and then 
> {noformat}
> JsonODataErrorDeserializer
> {noformat}
> 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
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)