Skip to content

Calling no-arg LoggingHandler constructor calls fails with NPE #842

Closed
@nresare

Description

@nresare

Attempting to follow the instructions in README.md to add the LoggingHandler via logging.properties it seems this always fails as of v3.6.0 with a NullPointerException due to the change introduced in bb25d5d. With a no-arg constructor, options will be null and line 244 will fail to call the getAutoPopulateMetadata() on that null reference.

To be able to the the mechanism where qualified classnames of subclasses to java.util.logging.Handler are added to a handlers property in logging.properties, a public no-arg constructor needs to be available. There is also a code example with a no-arg constructor in README.md

Steps to reproduce:

  • Add a call new LoggingHandler() anywhere, for example in a unit test and run it

Expected outcome:
No exception raised

Actual outcome:
A NullPointerException is raised:

java.lang.NullPointerException
	at com.google.cloud.logging.LoggingHandler.<init>(LoggingHandler.java:244)
	at com.google.cloud.logging.LoggingHandler.<init>(LoggingHandler.java:193)
	at com.google.cloud.logging.LoggingHandler.<init>(LoggingHandler.java:162)

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/java-logging API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.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