johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hendrik Saly (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FLEECE-7) JsonValue.java (json_1.0_spec) throws NPE
Date Fri, 11 Jul 2014 23:21:04 GMT

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

Hendrik Saly updated FLEECE-7:
------------------------------

    Description: 
On line 38 in the file http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.0_spec/src/main/java/javax/json/JsonValue.java?revision=1598683&view=markup
a NPE will occur.

{code}
public String toString() {
     return String.valueOf(null); //Line 38
}
{code}

String.valueOf(null) is translated to String.valueOf((char[]) null) and that gives a NPE.

This can be fixed with
{code}
return String.valueOf((String)null));

//or just

return "null";
{code}

Consequence is that a test like the below would fail with NullPointerException:

{code}
@Test
public void nullLiteralArray() {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();      
        Json.createGenerator(baos).writeStartArray().writeNull().write(JsonValue.NULL).writeEnd().close();
        assertEquals("[null,null]", new String(baos.toByteArray()));
}
{code}

  was:
On line 38 in the file http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.0_spec/src/main/java/javax/json/JsonValue.java?revision=1598683&view=markup
a NPE will occur.

public String toString() {

38:   return String.valueOf(null);

}


String.valueOf(null) is translated to String.valueOf((char[]) null) and that gives a NPE.

This can be fixed with

return String.valueOf((String)null));

or just

return "null";


Consequence is that a test like the below would fail with NullPointerException:

@Test
    public void nullLiteralArray() {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();      Json.createGenerator(baos).writeStartArray().writeNull().write(JsonValue.NULL).writeEnd().close();
        assertEquals("[null,null]", new String(baos.toByteArray()));
    }



> JsonValue.java (json_1.0_spec) throws NPE
> -----------------------------------------
>
>                 Key: FLEECE-7
>                 URL: https://issues.apache.org/jira/browse/FLEECE-7
>             Project: Fleece
>          Issue Type: Bug
>            Reporter: Hendrik Saly
>            Priority: Blocker
>
> On line 38 in the file http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-json_1.0_spec/src/main/java/javax/json/JsonValue.java?revision=1598683&view=markup
a NPE will occur.
> {code}
> public String toString() {
>      return String.valueOf(null); //Line 38
> }
> {code}
> String.valueOf(null) is translated to String.valueOf((char[]) null) and that gives a
NPE.
> This can be fixed with
> {code}
> return String.valueOf((String)null));
> //or just
> return "null";
> {code}
> Consequence is that a test like the below would fail with NullPointerException:
> {code}
> @Test
> public void nullLiteralArray() {
>         final ByteArrayOutputStream baos = new ByteArrayOutputStream();      
>         Json.createGenerator(baos).writeStartArray().writeNull().write(JsonValue.NULL).writeEnd().close();
>         assertEquals("[null,null]", new String(baos.toByteArray()));
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message