GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ServiceOptions.getCredentials can return null and cause NPE in Logging and PubSub · Issue #1565 · googleapis/google-cloud-java

ServiceOptions.getCredentials can return null and cause NPE in Logging and PubSub #1565

New issue
Copy link
New issue
Copy link
Closed
#1955
Closed
ServiceOptions.getCredentials can return null and cause NPE in Logging and PubSub#1565
#1955
Copy link
Assignees
neozwu
Labels
api: loggingIssues related to the Cloud Logging API.api: pubsubIssues related to the Pub/Sub API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@vkedia
vkedia
opened on Jan 25, 2017
Issue body actions

In ServiceOptions.java is no credentials are explicitly specified, it would default to calling getApplicationDefault here:
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L312

But that method can fail by throwing an exception if for eg the credentials file is missing. In that case ServiceOptions just catches the exception, ignores it and returns null:
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L314

But reading the documentation on getCredentials, it is not clear that callers should be handling null return value. google-cloud-java seems to be not handling the null return value atleast in couple of places:
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/00add6e26fc2e1a533b715df28a5568222483f65/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/DefaultLoggingRpc.java#L117
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/00add6e26fc2e1a533b715df28a5568222483f65/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/DefaultPubSubRpc.java#L146

Activity

Next
  1. garrettjonesgoogle
    added
    blocking GA
    api: loggingIssues related to the Cloud Logging API.
    on Jan 26, 2017
  2. garrettjonesgoogle
    changed the title [-]ServiceOptions.getCredentials can return null[/-] [+]ServiceOptions.getCredentials can return null and cause NPE in Logging and PubSub[/+] on Jan 26, 2017
  3. danoscarmike
    added
    release-blocking
    Status: Release Blocking
    and removed
    release-blocking
    on Feb 20, 2017
  4. garrettjonesgoogle
    added
    api: pubsubIssues related to the Pub/Sub API.
    on Mar 1, 2017
  5. garrettjonesgoogle
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    and removed
    blocking GA
    on Mar 10, 2017
  6. garrettjonesgoogle
    assigned
    neozwu
    on Apr 17, 2017
  7. neozwu
    closed this as completedin #1955on Apr 21, 2017
  8. neozwu
    added a commit that references this issue on Apr 21, 2017

    Fix credential NPE (#1955)

    This issue will close once commit ada4cd5 is merged into the 'main' branch.
    ada4cd5
  9. garrettjonesgoogle commented on Apr 21, 2017

    @garrettjonesgoogle
    garrettjonesgoogle
    on Apr 21, 2017
    Contributor
    More actions

    Re-opening because:

    • Fix credential NPE #1955 was rolled back because integration tests failed
    • Fix credential NPE #1955 only fixed Logging, not the rest of the APIs
  10. garrettjonesgoogle
    reopened this on Apr 21, 2017
  11. neozwu
    added a commit that references this issue on Apr 21, 2017

    fix credentials NPE bug googleapis#1565

    c3529a4
  12. 3 remaining items

  13. theacodes
    unassigned
    neozwu
    on Sep 28, 2018
  14. JustinBeckwith
    assigned
    neozwu
    on Feb 1, 2021
  15. neozwu
    removed their assignment
    on Feb 1, 2021
  16. JustinBeckwith
    assigned
    neozwu
    on Feb 1, 2021
  17. meltsufin
    added a commit that references this issue on Dec 22, 2025

    (#1565)

    447c82c
  18. chingor13
    added a commit that references this issue on Jan 6, 2026

    chore: add release-please config for protobuf-4.x (#1565)

    c6cd44f
  19. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(main): release 2.21.3 (#1565)

    7e7a030
  20. suztomo
    added a commit that references this issue on Mar 11, 2026

    (googleapis#1565)

    85f68a0
  21. lqiu96
    added a commit that references this issue on Mar 20, 2026

    chore: add release-please config for protobuf-4.x (#1565)

    9df0a67
  22. suztomo
    added a commit that references this issue on Mar 23, 2026

    deps: update dependency com.google.cloud:google-cloud-spanner-bom to …

    3d4d9c8
  23. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    78ac055
  24. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

    548f249
  25. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…

    3d7f0b0

    chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…

    8b46a59
  26. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v26.…

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

Metadata

Metadata

Assignees

  • @neozwu
    neozwu

Labels

api: loggingIssues related to the Cloud Logging API.api: pubsubIssues related to the Pub/Sub API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.