googleapis / googleapis/google-cloud-java

[java-logging] LoggingOptions.getDefaultInstance() always returns a new object

Open
#11,922 5 comments 0 reactions 1 assignee Claimed by @cindy-peng View on GitHub
api: logging next major: breaking change priority: p3 type: bug
Dominant language
Java
Stars
2.1k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
154

Description

`LoggingOptions.getDefaultInstance()` always returns a new object:

```java
public static LoggingOptions getDefaultInstance() {
return newBuilder().build();
}
```

This is very misleading, because the method name suggests it will return the same instance.

Consequences are that `Logging` instance is not shared among handlers etc. if we use `LoggingOptions.getDefaultInstance()` to pass the options, without saving them to a variable.

In fact, our codebase had `LoggingOptions.getDefaultInstance().service` in a few places, and a new client was always created as a result.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.