artiya4u / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

"null for field null" in exception message #136

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?
 - google-http-client-1.10.3-beta
 - google-api-services-fusiontables-v1-rev1-1.7.2-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
  java version "1.6.0_26"
  Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
  Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Describe the problem.

When trying to parse JSON responses from Google Fusion Tables the   JsonParser 
quits with the following StackTrace

Exception in thread "main" java.lang.IllegalArgumentException: null for field 
null
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:621)
    at com.google.api.client.json.JsonParser.parseArray(JsonParser.java:459)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:525)
    at com.google.api.client.json.JsonParser.parseArray(JsonParser.java:459)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:525)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:357)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:563)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:296)
    at com.google.api.client.json.JsonParser.parse(JsonParser.java:273)
    at com.google.api.client.json.JsonParser.parseAndClose(JsonParser.java:148)
    at com.google.api.client.http.json.JsonHttpParser.parse(JsonHttpParser.java:90)
    at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:499)
    at com.google.api.services.fusiontables.Fusiontables$Query$SqlGet.execute(Fusiontables.java:1038)
    at com.phasr.spatial.trackfusion.ApiTest.main(ApiTest.java:44)
Caused by: java.lang.IllegalArgumentException: expected primitive class, but 
got: java.util.List<java.lang.Object>
    at com.google.api.client.util.Data.parsePrimitiveValue(Data.java:451)
    at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:619)
    ... 13 more

It is reproducable with the following JSON

{
    "kind": "fusiontables#sqlresponse",
    "columns": [
        "rowid"
    ],
    "rows": [
        [
            "2801"
        ],
        [
            "2802"
        ]
    ]
}

or with the following SELECT statement

SELECT ROWID FROM 1KxVV0wQXhxhMScSDuqr-0Ebf0YEt4m4xzVplKd4

How would you expect it to be fixed?

I tried to fix it. At first I tried other JSON parser (GSON, Jackson and native 
Android JSON Parser), but the error is always the same. There must something 
wrong with parsing the array:

"rows": [
        [
            "2801"
        ],
        [
            "2802"
        ]
    ]

Original issue reported on code.google.com by christ...@christianjunk.de on 29 Jun 2012 at 9:18

GoogleCodeExporter commented 9 years ago
Try this to reproduce:

 JsonFactory jsonFactory = new JacksonFactory();

        com.google.api.client.json.JsonParser parser = jsonFactory.createJsonParser("{\n" +
                "    \"kind\": \"fusiontables#sqlresponse\",\n" +
                "    \"columns\": [\n" +
                "        \"rowid\"\n" +
                "    ],\n" +
                "    \"rows\": [\n" +
                "        [\n" +
                "            \"2801\"\n" +
                "        ],\n" +
                "        [\n" +
                "            \"2802\"\n" +
                "        ]\n" +
                "    ]\n" +
                "}");

        parser.parse(Sqlresponse.class, null);

Original comment by christ...@christianjunk.de on 30 Jun 2012 at 11:57

GoogleCodeExporter commented 9 years ago
I found the bug. It is no bug in the 'google-http-java-client' library. It is a 
bug in the 'google-api-services-fusiontables-v1-rev1-1.7.2-beta' library. It 
seems that there is an problem with the 
'com.google.api.services.fusiontables.model.Sqlresponse' class. I will post it 
to the Fusion Tables API Users Group.

Regards,
Christian

Original comment by christ...@christianjunk.de on 30 Jun 2012 at 12:23

GoogleCodeExporter commented 9 years ago
Thanks for reporting the problem.  This issue has now been moved to:

http://code.google.com/p/google-api-java-client/issues/detail?id=545

But I noticed one minor problem: I don't like the exception message "null for 
field null".  If you don't mind, I'll keep this issue to fix that message.

Original comment by yan...@google.com on 9 Jul 2012 at 6:45

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 24 Oct 2012 at 5:42

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 13 Dec 2012 at 2:38

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/6447088/

Original comment by yan...@google.com on 27 Dec 2012 at 6:11