NPE on GenericURL class on v1.20

18 views
Skip to first unread message

Paulo Fernandes

unread,
Jul 13, 2018, 12:05:45 PM7/13/18
to google-http-java-client
Hi all,
i have a server in production using google-http-java-client 1.20 , and i'm casually getting npe at GenericUrl.java:599, the cause is the fact that "value" is somethimes null..


  private static boolean appendParam(boolean first, StringBuilder buf, String name, Object value) {
    if (first) {
      first = false;
      buf.append('?');
    } else {
      buf.append('&');
    }
    buf.append(name);
------>  String stringValue = CharEscapers.escapeUriQuery(value.toString());
    if (stringValue.length() != 0) {
      buf.append('=').append(stringValue);
    }
    return first;
  }

java.lang.NullPointerException
at com.google.api.client.http.GenericUrl.appendParam(GenericUrl.java:599)
at com.google.api.client.http.GenericUrl.addQueryParams(GenericUrl.java:582)
at com.google.api.client.http.UriTemplate.expand(UriTemplate.java:346)
at com.google.api.client.http.UriTemplate.expand(UriTemplate.java:259)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequestUrl(AbstractGoogleClientRequest.java:265)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:300)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
...

the request is for google translate. in order to  debug this issue i built a lot of diferent tests calling UriTemplate  (the class that will call GenericUrl.java) "expand" method, passing all types of possible parameter combinations, and i never managed to reproduce this error locally..

has anyone ever faced this issue ? maybe even using libraries other than googel translate..


Thanks,
Paulo f
Reply all
Reply to author
Forward
0 new messages