This rule flags the use of the java.nio.channels.FileChannel.lock() method. In Java SE 6 the lock() method now throws java.nio.channels.OverlappingFileLockException .
This rule will flag the lock() method that does not have a try/catch block with OverlappingFileLockException or if the surrounding method does not throw OverlappingFileLockException .
Example 1:
Example 2:
Example 3:
In example 1, the fc.lock() call will get flagged.
In example 2, the super.lock() call will get flagged.
In example 3, nothing will get flagged, because the doX() method already throws OverlappingFileLockException and the doY() method catches OverlappingFileLockException .
Java SE 6 added the system property sun.nio.ch.disableSystemWideOverlappingFileLockCheck to control java.nio.channels.FileChannel.lock file checking behavior.
For additional information, see item 4 in the Java SE 6 Compatibility guide.