You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by Reinhard Sandtner <re...@gmail.com> on 2016/11/24 09:47:27 UTC

JsonObject#get* behavior

hey folks,

while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes apparent that our behavior for the get*-methods in JsonObject differs with the implementation in the unoffical RI.

if a key does not exist, we throw a NPE while the spec says it should return null (https://github.com/json-processing-inofficial/jsonp/blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <https://github.com/json-processing-inofficial/jsonp/blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)


     * @return the object value to which the specified name is mapped, or
     *         {@code null} if this object contains no mapping for the name


imo we should fix it - know the big question: 
fix it only in jsonp-1.1 or also in jsonp-1.0?

lg
reini

Re: JsonObject#get* behavior

Posted by Mark Struberg <st...@yahoo.de.INVALID>.
Oki, so the API is correct but the RI is wrong, got it.

LieGrue,
strub


> Am 24.11.2016 um 11:18 schrieb Reinhard Sandtner <re...@gmail.com>:
> 
> mark,
> 
> they didn’t! javadoc for 1.0 and 1.1 says the same 
> Throws:
> NullPointerException <http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true> - if the specified name doesn't have any mapping
> 
> ‚only' the unoffical jsonp on github is wrong
> 
> not sure where to open a ticket, should i add one here https://java.net/jira/browse/JSON_PROCESSING_SPEC <https://java.net/jira/browse/JSON_PROCESSING_SPEC> ?
> 
> 
>> Am 24.11.2016 um 11:12 schrieb Mark Struberg <st...@yahoo.de.INVALID>:
>> 
>> Actually good noise ;)
>> 
>> Could you please open a JSON-P 1.1 ticket?
>> They must not change the behaviour from one spec release to the next!
>> This is forbidden by the JCP rules for specs.
>> 
>> LieGrue,
>> strub
>> 
>> 
>>> Am 24.11.2016 um 11:08 schrieb Reinhard Sandtner <re...@gmail.com>:
>>> 
>>> ok guys,
>>> 
>>> i checked the javadoc from the JCP and we are perfectly fine with our implementation ;)
>>> 
>>> the unoffical RI does not respect it
>>> 
>>> jsonp-1.0 - http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html <http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html>
>>> jsonp-1.1 - http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html <http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html>
>>> 
>>> sorry for the noise :)
>>> 
>>> lg
>>> reini
>>> 
>>>> Am 24.11.2016 um 10:50 schrieb Romain Manni-Bucau <rm...@gmail.com>:
>>>> 
>>>> Hmm,
>>>> 
>>>> can we check before it is not a regression? I thought it was the first impl
>>>> and I doubt we throw an exception there for fun (I hate to check the key
>>>> exists before getting it to be honest). If not in jsonp 1.0 then +1 to fix
>>>> it in both.
>>>> 
>>>> 
>>>> Romain Manni-Bucau
>>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>>> <https://blog-rmannibucau.rhcloud.com> | Old Blog
>>>> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
>>>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
>>>> <https://javaeefactory-rmannibucau.rhcloud.com>
>>>> 
>>>> 2016-11-24 10:47 GMT+01:00 Reinhard Sandtner <re...@gmail.com>:
>>>> 
>>>>> hey folks,
>>>>> 
>>>>> while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes
>>>>> apparent that our behavior for the get*-methods in JsonObject differs with
>>>>> the implementation in the unoffical RI.
>>>>> 
>>>>> if a key does not exist, we throw a NPE while the spec says it should
>>>>> return null (https://github.com/json-processing-inofficial/jsonp/
>>>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <
>>>>> https://github.com/json-processing-inofficial/jsonp/
>>>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)
>>>>> 
>>>>> 
>>>>>  * @return the object value to which the specified name is mapped, or
>>>>>  *         {@code null} if this object contains no mapping for the name
>>>>> 
>>>>> 
>>>>> imo we should fix it - know the big question:
>>>>> fix it only in jsonp-1.1 or also in jsonp-1.0?
>>>>> 
>>>>> lg
>>>>> reini
>>> 
>> 
> 


Re: JsonObject#get* behavior

Posted by Reinhard Sandtner <re...@gmail.com>.
mark,

they didn’t! javadoc for 1.0 and 1.1 says the same 
Throws:
NullPointerException <http://docs.oracle.com/javase/7/docs/api/java/lang/NullPointerException.html?is-external=true> - if the specified name doesn't have any mapping

 ‚only' the unoffical jsonp on github is wrong

not sure where to open a ticket, should i add one here https://java.net/jira/browse/JSON_PROCESSING_SPEC <https://java.net/jira/browse/JSON_PROCESSING_SPEC> ?


> Am 24.11.2016 um 11:12 schrieb Mark Struberg <st...@yahoo.de.INVALID>:
> 
> Actually good noise ;)
> 
> Could you please open a JSON-P 1.1 ticket?
> They must not change the behaviour from one spec release to the next!
> This is forbidden by the JCP rules for specs.
> 
> LieGrue,
> strub
> 
> 
>> Am 24.11.2016 um 11:08 schrieb Reinhard Sandtner <re...@gmail.com>:
>> 
>> ok guys,
>> 
>> i checked the javadoc from the JCP and we are perfectly fine with our implementation ;)
>> 
>> the unoffical RI does not respect it
>> 
>> jsonp-1.0 - http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html <http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html>
>> jsonp-1.1 - http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html <http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html>
>> 
>> sorry for the noise :)
>> 
>> lg
>> reini
>> 
>>> Am 24.11.2016 um 10:50 schrieb Romain Manni-Bucau <rm...@gmail.com>:
>>> 
>>> Hmm,
>>> 
>>> can we check before it is not a regression? I thought it was the first impl
>>> and I doubt we throw an exception there for fun (I hate to check the key
>>> exists before getting it to be honest). If not in jsonp 1.0 then +1 to fix
>>> it in both.
>>> 
>>> 
>>> Romain Manni-Bucau
>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>> <https://blog-rmannibucau.rhcloud.com> | Old Blog
>>> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
>>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
>>> <https://javaeefactory-rmannibucau.rhcloud.com>
>>> 
>>> 2016-11-24 10:47 GMT+01:00 Reinhard Sandtner <re...@gmail.com>:
>>> 
>>>> hey folks,
>>>> 
>>>> while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes
>>>> apparent that our behavior for the get*-methods in JsonObject differs with
>>>> the implementation in the unoffical RI.
>>>> 
>>>> if a key does not exist, we throw a NPE while the spec says it should
>>>> return null (https://github.com/json-processing-inofficial/jsonp/
>>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <
>>>> https://github.com/json-processing-inofficial/jsonp/
>>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)
>>>> 
>>>> 
>>>>   * @return the object value to which the specified name is mapped, or
>>>>   *         {@code null} if this object contains no mapping for the name
>>>> 
>>>> 
>>>> imo we should fix it - know the big question:
>>>> fix it only in jsonp-1.1 or also in jsonp-1.0?
>>>> 
>>>> lg
>>>> reini
>> 
> 


Re: JsonObject#get* behavior

Posted by Mark Struberg <st...@yahoo.de.INVALID>.
Actually good noise ;)

Could you please open a JSON-P 1.1 ticket?
They must not change the behaviour from one spec release to the next!
This is forbidden by the JCP rules for specs.

LieGrue,
strub


> Am 24.11.2016 um 11:08 schrieb Reinhard Sandtner <re...@gmail.com>:
> 
> ok guys,
> 
> i checked the javadoc from the JCP and we are perfectly fine with our implementation ;)
> 
> the unoffical RI does not respect it
> 
> jsonp-1.0 - http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html <http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html>
> jsonp-1.1 - http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html <http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html>
> 
> sorry for the noise :)
> 
> lg
> reini
> 
>> Am 24.11.2016 um 10:50 schrieb Romain Manni-Bucau <rm...@gmail.com>:
>> 
>> Hmm,
>> 
>> can we check before it is not a regression? I thought it was the first impl
>> and I doubt we throw an exception there for fun (I hate to check the key
>> exists before getting it to be honest). If not in jsonp 1.0 then +1 to fix
>> it in both.
>> 
>> 
>> Romain Manni-Bucau
>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>> <https://blog-rmannibucau.rhcloud.com> | Old Blog
>> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
>> <https://javaeefactory-rmannibucau.rhcloud.com>
>> 
>> 2016-11-24 10:47 GMT+01:00 Reinhard Sandtner <re...@gmail.com>:
>> 
>>> hey folks,
>>> 
>>> while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes
>>> apparent that our behavior for the get*-methods in JsonObject differs with
>>> the implementation in the unoffical RI.
>>> 
>>> if a key does not exist, we throw a NPE while the spec says it should
>>> return null (https://github.com/json-processing-inofficial/jsonp/
>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <
>>> https://github.com/json-processing-inofficial/jsonp/
>>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)
>>> 
>>> 
>>>    * @return the object value to which the specified name is mapped, or
>>>    *         {@code null} if this object contains no mapping for the name
>>> 
>>> 
>>> imo we should fix it - know the big question:
>>> fix it only in jsonp-1.1 or also in jsonp-1.0?
>>> 
>>> lg
>>> reini
> 


Re: JsonObject#get* behavior

Posted by Reinhard Sandtner <re...@gmail.com>.
ok guys,

i checked the javadoc from the JCP and we are perfectly fine with our implementation ;)

the unoffical RI does not respect it

jsonp-1.0 - http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html <http://download.oracle.com/otndocs/jcp/json-1_0-fr-eval-spec/index.html>
jsonp-1.1 - http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html <http://download.oracle.com/otndocs/jcp/json_p-1_1-edr-spec/index.html>

sorry for the noise :)

lg
reini

> Am 24.11.2016 um 10:50 schrieb Romain Manni-Bucau <rm...@gmail.com>:
> 
> Hmm,
> 
> can we check before it is not a regression? I thought it was the first impl
> and I doubt we throw an exception there for fun (I hate to check the key
> exists before getting it to be honest). If not in jsonp 1.0 then +1 to fix
> it in both.
> 
> 
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
> 
> 2016-11-24 10:47 GMT+01:00 Reinhard Sandtner <re...@gmail.com>:
> 
>> hey folks,
>> 
>> while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes
>> apparent that our behavior for the get*-methods in JsonObject differs with
>> the implementation in the unoffical RI.
>> 
>> if a key does not exist, we throw a NPE while the spec says it should
>> return null (https://github.com/json-processing-inofficial/jsonp/
>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <
>> https://github.com/json-processing-inofficial/jsonp/
>> blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)
>> 
>> 
>>     * @return the object value to which the specified name is mapped, or
>>     *         {@code null} if this object contains no mapping for the name
>> 
>> 
>> imo we should fix it - know the big question:
>> fix it only in jsonp-1.1 or also in jsonp-1.0?
>> 
>> lg
>> reini


Re: JsonObject#get* behavior

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hmm,

can we check before it is not a regression? I thought it was the first impl
and I doubt we throw an exception there for fun (I hate to check the key
exists before getting it to be honest). If not in jsonp 1.0 then +1 to fix
it in both.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-11-24 10:47 GMT+01:00 Reinhard Sandtner <re...@gmail.com>:

> hey folks,
>
> while writing tests for JsonPatch in our JSONP-1.1 branch, it becomes
> apparent that our behavior for the get*-methods in JsonObject differs with
> the implementation in the unoffical RI.
>
> if a key does not exist, we throw a NPE while the spec says it should
> return null (https://github.com/json-processing-inofficial/jsonp/
> blob/master/api/src/main/java/javax/json/JsonObject.java#L149 <
> https://github.com/json-processing-inofficial/jsonp/
> blob/master/api/src/main/java/javax/json/JsonObject.java#L149>)
>
>
>      * @return the object value to which the specified name is mapped, or
>      *         {@code null} if this object contains no mapping for the name
>
>
> imo we should fix it - know the big question:
> fix it only in jsonp-1.1 or also in jsonp-1.0?
>
> lg
> reini