You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Tom van Wietmarschen <aa...@gmail.com> on 2016/04/29 11:00:57 UTC

OLingo 4.2.0 client NPE's on null enum value

I encountered the following NPE while trying to read an Entity that has a null value for an Enum type. 

java.lang.NullPointerException
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataValue(ODataBinderImpl.java:820)
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataProperty(ODataBinderImpl.java:790)
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataValue(ODataBinderImpl.java:839)
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataProperty(ODataBinderImpl.java:790)
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataEntity(ODataBinderImpl.java:713)
	at org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataEntitySet(ODataBinderImpl.java:419)
	at org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl$ODataEntitySetResponseImpl.getBody(ODataEntitySetRequestImpl.java:85)
	at org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl$ODataEntitySetResponseImpl.getBody(ODataEntitySetRequestImpl.java:68)
	at <our sample code unit test>.documentListPagination(DocumentationSamples.java:67)

As per OData v4.0 Part 3 section 6.2.1 , all fields are nullable unless otherwise specified (I didn't specify it for this enum, there is no Nullable attribute in de metadata). So as far as I can tell it *should* be able to read a null value for an enum. Looking at the source there seems to be no check if the property is nullable and it does a toString() directly on the (null) value object.

Am I misinterpreting the spec or is this a bug in the Olingo client code ?

The version of OLingo I'm using: 

<dependency>
	<groupId>org.apache.olingo</groupId>
	<artifactId>odata-client-core</artifactId>
	<version>4.2.0</version>
</dependency>


Sincerely, 
Tom van Wietmarschen

Re: OLingo 4.2.0 client NPE's on null enum value

Posted by Ramesh Reddy <ra...@redhat.com>.
You should open a JIRA for this. Then you can contribute the fix, or we will try to get it into 4.3 release as possible. 

----- Original Message -----

> I encountered the following NPE while trying to read an Entity that has a
> null value for an Enum type.

> java.lang.NullPointerException
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataValue(ODataBinderImpl.java:820)
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataProperty(ODataBinderImpl.java:790)
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataValue(ODataBinderImpl.java:839)
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataProperty(ODataBinderImpl.java:790)
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataEntity(ODataBinderImpl.java:713)
> at
> org.apache.olingo.client.core.serialization.ODataBinderImpl.getODataEntitySet(ODataBinderImpl.java:419)
> at
> org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl$ODataEntitySetResponseImpl.getBody(ODataEntitySetRequestImpl.java:85)
> at
> org.apache.olingo.client.core.communication.request.retrieve.ODataEntitySetRequestImpl$ODataEntitySetResponseImpl.getBody(ODataEntitySetRequestImpl.java:68)
> at <our sample code unit
> test>.documentListPagination(DocumentationSamples.java:67)

> As per OData v4.0 Part 3 section 6.2.1 , all fields are nullable unless
> otherwise specified (I didn't specify it for this enum, there is no Nullable
> attribute in de metadata). So as far as I can tell it *should* be able to
> read a null value for an enum. Looking at the source there seems to be no
> check if the property is nullable and it does a toString() directly on the
> (null) value object.

> Am I misinterpreting the spec or is this a bug in the Olingo client code ?

> The version of OLingo I'm using:

> <dependency>
> <groupId>org.apache.olingo</groupId>
> <artifactId> odata -client-core</artifactId>
> <version>4.2.0</version>
> </dependency>

> Sincerely,
> Tom van Wietmarschen