eclipse-ee4j / grizzly

Grizzly
https://eclipse-ee4j.github.io/grizzly
Other
147 stars 68 forks source link

SpotBugs analysis: Holder.toString() may return null #2182

Closed ghost closed 11 months ago

ghost commented 1 year ago

Would returning "null", rather than null, be more idiomatic?

https://github.com/eclipse-ee4j/grizzly/blob/a2ce7775658e11fbccbb9acd32e2daf2b0799f45/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/Holder.java#L70

toString method may return null This toString method seems to return null in some circumstances. A liberal reading of the spec could be interpreted as allowing this, but it is probably a bad idea and could cause other code to break. Return the empty string or some other appropriate string rather than null.

Since at least 2.3.25.

Consider:

return obj == null ? "null" : "{" + obj + "}";
mnriem commented 11 months ago

@DaveJarvis Would you consider "{}" instead as the Holder object itself does exist, but rather it has nothing to hold onto?

mnriem commented 11 months ago

@DaveJarvis Can you create a PR for this?

ghost commented 11 months ago

@DaveJarvis Can you create a PR for this?

No, I'm moving off of GitHub soon.