-
Notifications
You must be signed in to change notification settings - Fork 906
Add a null check in ProxyConfiguration to avoid a NullPointerException when calling toBuilder #2907
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
Conversation
…n when calling toBuilder
if (nonProxyHosts != null) { | ||
this.nonProxyHosts = new HashSet<>(nonProxyHosts); | ||
} else { | ||
this.nonProxyHosts = Collections.emptySet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we force the Null Value to be assigned as Empty set then it might break the below code
Lines 131 to 145 in 584ccb5
/** | |
* The hosts that the client is allowed to access without going through the proxy. | |
* | |
* If the value is not set on the object, the value represent by "http.nonProxyHosts" system property is returned. | |
* If system property is also not set, an unmodifiable empty set is returned. | |
* | |
* @see Builder#nonProxyHosts(Set) | |
*/ | |
public Set<String> nonProxyHosts() { | |
Set<String> hosts = nonProxyHosts == null && useSystemPropertyValues ? parseNonProxyHostsProperty() | |
: nonProxyHosts; | |
return Collections.unmodifiableSet(hosts != null ? hosts : Collections.emptySet()); | |
} | |
Here we do a null check on nonProxyHosts , if user set the value of nonProxyHosts as null internally we changing it to Collections.emptySet() might affect the getter public Set<String> nonProxyHosts()
Why don't we just do something s below
@Override
public Builder nonProxyHosts(Set<String> nonProxyHosts) {
this.nonProxyHosts = nonProxyHosts != null ? new HashSet<>(nonProxyHosts) : null;
return this;
}
Kudos, SonarCloud Quality Gate passed! |
…08d78b610 Pull request: release <- staging/d13c4c80-18cd-4379-9d90-a1708d78b610
Motivation and Context
Fixes #2884
Types of changes
Checklist
mvn install
succeedsLicense