[tor-bugs] #15654 [Onionoo]: proper closing of BufferedWriter in LockFile.java

Tor Bug Tracker & Wiki blackhole at torproject.org
Sun May 10 19:22:11 UTC 2015


#15654: proper closing of BufferedWriter in LockFile.java
-----------------------------+-----------------
     Reporter:  firebrand    |      Owner:
         Type:  enhancement  |     Status:  new
     Priority:  trivial      |  Milestone:
    Component:  Onionoo      |    Version:
   Resolution:               |   Keywords:
Actual Points:               |  Parent ID:
       Points:               |
-----------------------------+-----------------

Comment (by iwakeh):

 Hi firebrand,

 thanks for the second patch!

 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.

 Maybe you could redesign the solution a little?

 @karsten: what do you think?

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/15654#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list