square / tape

A lightning fast, transactional, file-based FIFO for Android and Java.
https://square.github.io/tape/
Apache License 2.0
2.47k stars 287 forks source link

File handle leak when exception in QueueFile construction #179

Closed chrissmith-mcafee closed 6 years ago

chrissmith-mcafee commented 6 years ago

Fixed issue where a file handle was being leaked when an exception occurred during construction of QueueFile.

This issue was discovered when attempting to delete the file associated with the QueueFile. The file was locked and couldn't be deleted (this only occurs on Windows as Linux does not prevent deletion).

In the fix, if any exceptions occur during the construction of QueueFile, the random access file is closed before returning.

chrissmith-mcafee commented 6 years ago

Appears there is a new issue with errorprone (unrelated to these changes) which is causing Travis CI to fail. The unit tests can be updated to use ArrayDeque versus LinkedList to solve this.

JakeWharton commented 6 years ago

We can fix that in a separate PR. The error-prone version should have been pinned so new checks don't fail on existing code.

On Tue, Nov 28, 2017 at 3:27 PM Chris Smith notifications@github.com wrote:

Appears there is a new issue with errorprone (unrelated to these changes) which is causing Travis CI to fail. The unit tests can be updated to use ArrayDeque versus LinkedList to solve this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/square/tape/pull/179#issuecomment-347653203, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEYsP5jAtSbDtvAznlZMOKELM_H0Vks5s7GzBgaJpZM4Qt2Qt .

NightlyNexus commented 6 years ago

sorry, that failure was my fault.

Is it alright to use try-with-resources? Tell Java 6 users to use desugar or similar?

JakeWharton commented 6 years ago

I don't think we should impose that just yet. Maybe in another year once D8 is widely deployed.

NightlyNexus commented 6 years ago

oh, sorry, i read this wrong. looks good.

JakeWharton commented 6 years ago

Thanks!