Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE because HTTP request initialized before setting URL #43

Closed
ajkannan opened this issue Nov 10, 2015 · 9 comments
Closed

NPE because HTTP request initialized before setting URL #43

ajkannan opened this issue Nov 10, 2015 · 9 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@ajkannan
Copy link

After updating google-auth-libraries to 0.3.0, we noticed the following stacktrace when using application default credentials:

com.google.gcloud.RetryHelper$NonRetriableException: java.lang.NullPointerException
    at com.google.gcloud.RetryHelper.doRetry(RetryHelper.java:193)
    at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:247)
    at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:237)
    at com.google.gcloud.storage.StorageImpl.listBuckets(StorageImpl.java:291)
    at com.google.gcloud.storage.StorageImpl.list(StorageImpl.java:285)
    at com.examples.example.Main.main(Main.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:61)
    at com.google.gcloud.ServiceOptions$1.initialize(ServiceOptions.java:513)
    at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
    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)
    at com.google.gcloud.spi.DefaultStorageRpc.list(DefaultStorageRpc.java:155)
    at com.google.gcloud.storage.StorageImpl$6.call(StorageImpl.java:295)
    at com.google.gcloud.storage.StorageImpl$6.call(StorageImpl.java:292)
    at com.google.gcloud.RetryHelper.doRetry(RetryHelper.java:181)

I think the issue was introduced in this commit. Also see https://github.com/google/google-auth-library-java/blame/master/oauth2_http/java/com/google/auth/http/HttpCredentialsAdapter.java#L61
The HTTP client's request factory seems to initialize the request before it sets the URL.

@aozarov
Copy link

aozarov commented Nov 10, 2015

/cc @aozarov

@anthmgoogle
Copy link
Contributor

A fix for this has been merged into google-auth-library-java by @pongad.

@ajkannan, @aozarov can you verify that it fixes the problem?

  1. Clone https://github.com/google/google-auth-library-java
  2. Run "mvn clean install" on the clone.
  3. Update your usage locally to use "0.4.0-SNAPSHOT".
  4. Run the original scenario to verify that it is fixed.

Once this is verified, we will either release a new version or patch the existing one.

@aozarov
Copy link

aozarov commented Nov 16, 2015

@ajkannan do you mind to verify it. I am pretty confident the fix is going to work.

@ajkannan
Copy link
Author

Sure, taking a look now.

@ajkannan
Copy link
Author

@anthmgoogle @aozarov The NPE issue is indeed fixed. I am however running into some issues using authentication from App Engine. When I’m authenticated with Google Cloud SDK and I try running my app on the dev app server (a local mock of production), I get an error message saying “The Application Default Credentials are not available” because I’m not running on Compute Engine and because I don’t have the GOOGLE_APPLICATION_CREDENTIALS environment variable set. I thought according to this documentation that the SDK credentials were supposed to be used first, before looking for App Engine credentials? I’m also having an issue in production with App Engine where I get the same error message as on the local development server (“The Application Default Credentials are not available”).

Authentication is working fine from Compute Engine and when using Google Cloud SDK on my desktop without App Engine.

@anthmgoogle
Copy link
Contributor

Thanks for confirming the issue is fixed. Let's keep this issue open
tracking getting the fix available in a release.

Can you start a new issue or issues about the App Engine problem or
problems?

On Tue, Nov 17, 2015 at 11:17 AM, Ajay Kannan notifications@github.com
wrote:

@anthmgoogle https://github.com/anthmgoogle @aozarov
https://github.com/aozarov The NPE issue is indeed fixed. I am however
running into some issues using authentication from App Engine. When I’m
authenticated with Google Cloud SDK and I try running my app on the dev app
server (a local mock of production), I get an error message saying “The
Application Default Credentials are not available” because I’m not running
on Compute Engine and because I don’t have the
GOOGLE_APPLICATION_CREDENTIALS environment variable set. I thought
according to this documentation
https://developers.google.com/identity/protocols/application-default-credentials
that the SDK credentials were supposed to be used first, before looking for
App Engine credentials? I’m also having an issue in production with App
Engine where I get the same error message as on the local development
server (“The Application Default Credentials are not available”).

Authentication is working fine from Compute Engine and when using Google
Cloud SDK on my desktop without App Engine.


Reply to this email directly or view it on GitHub
#43 (comment)
.

@ajkannan
Copy link
Author

Sure thing, will do.

@pongad
Copy link
Contributor

pongad commented Nov 18, 2015

This bug should be fixed by v0.3.1 . Could you verify?

@ajkannan
Copy link
Author

Yup, I've verified that the bug is fixed by v0.3.1.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants