...
Code Block | ||
---|---|---|
| ||
public final class Client { private final Lock lock = new ReentrantLock(); public void doSomething(File file) { InputStream in = null; try { lock.lock(in = new FileInputStream(file); in = new FileInputStream(filelock.lock(); // Perform operations on the open file lock.unlock(); } catch (FileNotFoundException x) { // Handle exception } finally { if (in != null) { try { in.close(); } catch (IOException x) { // Handle exception } } } } } |
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Parasoft Jtest |
| TRSCERT.LCK08.RLF BDCERT.TRSLCK08.LOCK | Release Locks in a "finally" block Do not abandon unreleased locks | ||||||
ThreadSafe |
| CCE_LK_UNRELEASED_ON_EXN | Implemented |
...