Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.
This repository was archived by the owner on May 12, 2026. It is now read-only.

NPE because HTTP request initialized before setting URL #43

Description

@ajkannan

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions