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 2017/07/20 09:04:33 UTC
OLingo client crashes when an enum property has a null value
Hi,
In my OData v4 service (Olingo 4.3.0) I have a few Enum properties that are nullable. When the value of these properties is null, the OLingo client (v4.3.0) throws an IllegalArgumentException when trying to access the property. Digging a bit further, it looks like the OLingo client never checks if an Enum property is null, it just calls Enum.valueOf with the String "null" as argument (org.apache.olingo.ext.proxy.utils.CoreUtils, line 336) , it explicitly checks for nulls on primitives (org.apache.olingo.ext.proxy.commons.AbstractStructuredInvocationHandler, line 378) but apparently Enum's aren't primitives, nor are they complex values (according to the OData v4 spec, as far as I can tell).
Looking at OData v4.0, part 3, section 6.2.1 and 10.1, there is nothing in the spec indicating that Enum's can't be nullable. For now, I can work around it by adding a 'NULL' or 'NOT_SET' or equivalent values to my enums but it does seem like a bug to me.
/Tom
Re: OLingo client crashes when an enum property has a null value
Posted by Tom van Wietmarschen <aa...@gmail.com>.
Ticket + patch submitted: https://issues.apache.org/jira/browse/OLINGO-1152 <https://issues.apache.org/jira/browse/OLINGO-1152>
/Tom
> On 20 Jul 2017, at 11:04, Tom van Wietmarschen <aa...@gmail.com> wrote:
>
> Hi,
>
> In my OData v4 service (Olingo 4.3.0) I have a few Enum properties that are nullable. When the value of these properties is null, the OLingo client (v4.3.0) throws an IllegalArgumentException when trying to access the property. Digging a bit further, it looks like the OLingo client never checks if an Enum property is null, it just calls Enum.valueOf with the String "null" as argument (org.apache.olingo.ext.proxy.utils.CoreUtils, line 336) , it explicitly checks for nulls on primitives (org.apache.olingo.ext.proxy.commons.AbstractStructuredInvocationHandler, line 378) but apparently Enum's aren't primitives, nor are they complex values (according to the OData v4 spec, as far as I can tell).
>
> Looking at OData v4.0, part 3, section 6.2.1 and 10.1, there is nothing in the spec indicating that Enum's can't be nullable. For now, I can work around it by adding a 'NULL' or 'NOT_SET' or equivalent values to my enums but it does seem like a bug to me.
>
> /Tom