matsudakazumi / google-api-java-client

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

FindBugs found: Dereferencing transport without confirming is not null #254

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the two places below, the transport field is dereferenced without checking 
that it was initialized:

api.client.googleapis.auth.clientlogin.ClientLogin

  public Response authenticate() throws HttpResponseException, IOException {
    GenericUrl url = serverUrl.clone();
    url.appendRawPath("/accounts/ClientLogin");
    HttpRequest request =
        transport.createRequestFactory().buildPostRequest(url, new UrlEncodedContent(this));
    request.addParser(AuthKeyValueParser.INSTANCE);
    request.setDisableContentLogging(true);
    return request.execute().parseAs(Response.class);
  }

api.client.googleapis.json

  private HttpRequest internalExecute(Object data) {
    JsonHttpContent content = new JsonHttpContent(jsonFactory, data);
    content.setType(contentType);
    HttpRequest httpRequest;
    try {
      httpRequest = transport.createRequestFactory().buildPostRequest(rpcServerUrl, content);
      httpRequest.getHeaders().setAccept(accept);
      return httpRequest;
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
  }

Original issue reported on code.google.com by avall...@google.com on 28 Jul 2011 at 3:34

GoogleCodeExporter commented 9 years ago
It's a special case of a general design issue that we will throw a 
NullPointerException if a required parameter is not set.  This will be fixed as 
part of Issue 45 in that required parameters will now be enforced to be 
required at compile time.

Original comment by yan...@google.com on 1 Aug 2011 at 9:23