-
Notifications
You must be signed in to change notification settings - Fork 232
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
Make SnappyOutputStream.close() idempotent; guard against writing to closed stream #108
Conversation
1285253
to
11f08de
Compare
b0f7c78
to
c1f6408
Compare
Here's a failing run of the regression test: https://travis-ci.org/xerial/snappy-java/jobs/62514893 |
c1f6408
to
2b6c8dc
Compare
Even though this patch makes |
Thanks for the fix. I think checking Please add both. |
I've updated this patch to include nulling of output buffers and |
WeakReference<byte[]> inputBuffer = new WeakReference<byte[]>(os.inputBuffer); | ||
WeakReference<byte[]> outputBuffer = new WeakReference<byte[]>(os.inputBuffer); | ||
os.close(); | ||
System.gc(); |
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.
Is this necessary?
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.
The goal here was to test that the now weakly-referencable buffers get reclaimed by GC.
Looks good! Thank you for the improvements. |
Make SnappyOutputStream.close() idempotent; guard against writing to closed stream
This patch will fix #107, an issue where
SnappyOutputStream.close()
is not idempotent.The first commit is a failing regression test which shows how a non-idempotent
close()
can lead to stream corruption issues.