tailorlala / guava-libraries

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

CountingOutputStream allegedly declares @Nullable out (wrapped), but will NPE #1869

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The constructor suggests that outputsteam may be null:

public CountingOutputStream(@Nullable OutputStream out)

But then any write/close operation will NPE:

@Override public void write(byte[] b, int off, int len) throws IOException {
    out.write(b, off, len);
    count += len;
}

Either the @Nullable annotation should be removed, or the write/close methods 
should only pass-through when out is non-null.

Original issue reported on code.google.com by anth...@whitford.com on 22 Oct 2014 at 1:01

GoogleCodeExporter commented 9 years ago
Thanks for the report. This does look like something that should be changed.

Original comment by cgdecker@google.com on 22 Oct 2014 at 4:37

GoogleCodeExporter commented 9 years ago
Technically the @Nullable on the parameter was correct since the constructor 
itself didn't throw NPE when null was passed to it. Overall, the behavior was 
obviously incorrect.

The parameters have been changed to non-@Nullable and the constructors have 
been changed to throw NPE when null is passed to them. The fix should be 
mirrored out soon.

Original comment by cgdecker@google.com on 23 Oct 2014 at 5:56

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

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

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

GoogleCodeExporter commented 9 years ago

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