The BufferedWriter in utils/LockFile.java should be closed inside a finally block. This ensures that the file handle is released even in presence of exceptions.
Trac: Username: firebrand
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
The nested try blocks are not exactly pretty. I wonder, should we switch to try-with-resources? There are probably quite a few similar places in the codebase that we should fix.
Updated the patch to not contain nested try blocks anymore. I took the first two statements out of the existing try block as they cannot throw an IOException anyways. I put them into their own block as they might throw a SecurityException if the location for the lock file is not readable or writable.
I think it's a good idea to really start using more java 7 features
(like try-with-resources) since onionoo was upgraded a while ago.
The SecurityException should not be discarded without any action.
We don't want to continue in case of a problem here.
The missing comment to the LockFile acquireLock method should
state something like the following:
/** * In case of any problem acquiring the lock file * <code>false</code> will be returned. * Only successful creation of a previously non-existant * lock file will lead to the return value <code>true</code>. * */
When you look at the usage of acquireLock you'll find
that the program terminates if it receives 'false'.
It is therefore important to return false after catching
any kind of Throwable and to log the error appropriately.
Thanks for the patch! The code looks good to me and passes local tests, the docs need tweaking. Please find branch task-15654 in my public repository for suggested fixes. If you like them, I'll squash and merge. Thanks!