Reputation: 14864
This bug is a bit of a mystery. I have a Google-Cloud-Endpoint method that returns List<String>
. Just before exiting the method, I log the content of the string as
LOG.info(“list has: " + results);
And when I check on app-engine’s log, I see the printout.
Now on the android side I read the content as
StringCollection collection = service.getResults().execute();
According to android LogCat that very line is throwing an exception blaming the server of returning a 500 error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code": 500,
"errors": [
{
"domain": "global",
"message": "Internal Error",
"reason": "internalError"
}
],
"message": "Internal Error"
}
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1045)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.business.game.pack.ServerCall$2.doInBackground(ServerCall.java:189)
at com.business.game.pack.ServerCall$2.doInBackground(ServerCall.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
I am not sure how to fix this error, as it seems to fall beyond my actual code.
Other attempts:
the endpoint used to return CollectionResponse.<String> builder().setItems(results).build()
. I change it to simply result
as troubleshooting but that didn’t help. So now the method signature (still failing) is
@ApiMethod(name = "getResults", httpMethod = HttpMethod.GET)
public List<String> getResults() {
LOG.info(“Into getResults");
//… more code
LOG.info(“list has: " + results);
return results;// CollectionResponse.<String> builder().setItems(results).build();
}
Thanks for any help.
Upvotes: 1
Views: 787
Reputation: 14864
The answer is quite crappy and I hope the google people resolve this. Evidently you cannot use String or a Collection of String as a return type. So that any of the following would fail:
return result;//String
return results;//List<String>
return CollectionResponse.<String> builder().setItems(results).build();
Instead you must create a wrapper that takes the string or collection thereof as field; a basic POJO.
This wasted a good 10hrs of my time. I hope it saves the next gal/guy some trouble.
Upvotes: 3