DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Preconditions.format possible NullPointerException #1701

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Within Preconditions.java you defined "args" as Nullable but in line 416 
(...new StringBuilder(template.length() + 16 * args.length);) a 
NullPointerException can be thrown!

I would expect at least the Nullable-Annotation should be removed (even for the 
calling methods, like checkNotNull) or it should be null-safe.

Original issue reported on code.google.com by soe...@glorien.com on 20 Mar 2014 at 6:43

GoogleCodeExporter commented 9 years ago
args is declared as @Nullable Object..., and I believe it was intended to 
indicate that the individual objects were permitted to be null, not the array 
itself.

Passing a null array to a varargs method would require an explicit cast, as I 
understand it -- (Object[]) null.  Is there a reason to believe this might 
actually cause issues in real code?

Original comment by lowas...@google.com on 20 Mar 2014 at 6:52

GoogleCodeExporter commented 9 years ago
To be honest, there is no real code error-szenario. It was just popping up 
during some tests and I was wondering that creation of error-message causes an 
error that was more or less unexpected.

Original comment by soe...@glorien.com on 20 Mar 2014 at 9:28

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07