Buggy code:
public class LockStressTest { public static void main ( String [ ] args ) throws Exception { if ( ( args . length ) != 6 ) { System . out . println ( ( "\nUsage:<seq2seq4repair_space>java<seq2seq4repair_space>org.apache.lucene.store.LockStressTest<seq2seq4repair_space>myID<seq2seq4repair_space>verifierHostOrIP<seq2seq4repair_space>verifierPort<seq2seq4repair_space>lockFactoryClassName<seq2seq4repair_space>lockDirName<seq2seq4repair_space>sleepTime\n" + ( ( ( ( ( ( ( ( ( ( ( ( ( "\n" + "<seq2seq4repair_space>myID<seq2seq4repair_space>=<seq2seq4repair_space>int<seq2seq4repair_space>from<seq2seq4repair_space>0<seq2seq4repair_space>..<seq2seq4repair_space>255<seq2seq4repair_space>(should<seq2seq4repair_space>be<seq2seq4repair_space>unique<seq2seq4repair_space>for<seq2seq4repair_space>test<seq2seq4repair_space>process)\n" ) + "<seq2seq4repair_space>verifierHostOrIP<seq2seq4repair_space>=<seq2seq4repair_space>host<seq2seq4repair_space>name<seq2seq4repair_space>or<seq2seq4repair_space>IP<seq2seq4repair_space>address<seq2seq4repair_space>where<seq2seq4repair_space>LockVerifyServer<seq2seq4repair_space>is<seq2seq4repair_space>running\n" ) + "<seq2seq4repair_space>verifierPort<seq2seq4repair_space>=<seq2seq4repair_space>port<seq2seq4repair_space>that<seq2seq4repair_space>LockVerifyServer<seq2seq4repair_space>is<seq2seq4repair_space>listening<seq2seq4repair_space>on\n" ) + "<seq2seq4repair_space>lockFactoryClassName<seq2seq4repair_space>=<seq2seq4repair_space>primary<seq2seq4repair_space>LockFactory<seq2seq4repair_space>class<seq2seq4repair_space>that<seq2seq4repair_space>we<seq2seq4repair_space>will<seq2seq4repair_space>use\n" ) + "<seq2seq4repair_space>lockDirName<seq2seq4repair_space>=<seq2seq4repair_space>path<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>lock<seq2seq4repair_space>directory<seq2seq4repair_space>(only<seq2seq4repair_space>set<seq2seq4repair_space>for<seq2seq4repair_space>Simple//NativeFSLockFactory\n" ) + "<seq2seq4repair_space>sleepTimeMS<seq2seq4repair_space>=<seq2seq4repair_space>milliseconds<seq2seq4repair_space>to<seq2seq4repair_space>pause<seq2seq4repair_space>betweeen<seq2seq4repair_space>each<seq2seq4repair_space>lock<seq2seq4repair_space>obtain//release\n" ) + "\n" ) + "You<seq2seq4repair_space>should<seq2seq4repair_space>run<seq2seq4repair_space>multiple<seq2seq4repair_space>instances<seq2seq4repair_space>of<seq2seq4repair_space>this<seq2seq4repair_space>process,<seq2seq4repair_space>each<seq2seq4repair_space>with<seq2seq4repair_space>its<seq2seq4repair_space>own\n" ) + "unique<seq2seq4repair_space>ID,<seq2seq4repair_space>and<seq2seq4repair_space>each<seq2seq4repair_space>pointing<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>lock<seq2seq4repair_space>directory,<seq2seq4repair_space>to<seq2seq4repair_space>verify\n" ) + "that<seq2seq4repair_space>locking<seq2seq4repair_space>is<seq2seq4repair_space>working<seq2seq4repair_space>correctly.\n" ) + "\n" ) + "Make<seq2seq4repair_space>sure<seq2seq4repair_space>you<seq2seq4repair_space>are<seq2seq4repair_space>first<seq2seq4repair_space>running<seq2seq4repair_space>LockVerifyServer.\n" ) + "\n" ) ) ) ; System . exit ( 1 ) ; } final int myID = Integer . parseInt ( args [ 0 ] ) ; if ( ( myID < 0 ) || ( myID > 255 ) ) { System . out . println ( "myID<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>a<seq2seq4repair_space>unique<seq2seq4repair_space>int<seq2seq4repair_space>0..255" ) ; System . exit ( 1 ) ; } final String verifierHost = args [ 1 ] ; final int verifierPort = Integer . parseInt ( args [ 2 ] ) ; final String lockFactoryClassName = args [ 3 ] ; final String lockDirName = args [ 4 ] ; final int sleepTimeMS = Integer . parseInt ( args [ 5 ] ) ; LockFactory lockFactory ; try { lockFactory = Class . forName ( lockFactoryClassName ) . asSubclass ( LockFactory . class ) . newInstance ( ) ; } catch ( IllegalAccessException e ) { throw new IOException ( ( "IllegalAccessException<seq2seq4repair_space>when<seq2seq4repair_space>instantiating<seq2seq4repair_space>LockClass<seq2seq4repair_space>" + lockFactoryClassName ) ) ; } catch ( InstantiationException e ) { throw new IOException ( ( "InstantiationException<seq2seq4repair_space>when<seq2seq4repair_space>instantiating<seq2seq4repair_space>LockClass<seq2seq4repair_space>" + lockFactoryClassName ) ) ; } catch ( ClassCastException e ) { throw new IOException ( ( ( "unable<seq2seq4repair_space>to<seq2seq4repair_space>cast<seq2seq4repair_space>LockClass<seq2seq4repair_space>" + lockFactoryClassName ) + "<seq2seq4repair_space>instance<seq2seq4repair_space>to<seq2seq4repair_space>a<seq2seq4repair_space>LockFactory" ) ) ; } catch ( ClassNotFoundException e ) { throw new IOException ( ( "unable<seq2seq4repair_space>to<seq2seq4repair_space>find<seq2seq4repair_space>LockClass<seq2seq4repair_space>" + lockFactoryClassName ) ) ; } File lockDir = new File ( lockDirName ) ; if ( lockFactory instanceof FSLockFactory ) { ( ( FSLockFactory ) ( lockFactory ) ) . setLockDir ( lockDir ) ; } lockFactory . setLockPrefix ( "test" ) ; LockFactory verifyLF = new VerifyingLockFactory ( ( ( byte ) ( myID ) ) , lockFactory , verifierHost , verifierPort ) ; Lock l = verifyLF . makeLock ( "test.lock" ) ; while ( true ) { boolean obtained = false ; try { obtained = l . obtain ( 10 ) ; } catch ( LockObtainFailedException e ) { System . out . print ( "x" ) ; } if ( obtained ) { System . out . print ( "l" ) ; <START_BUG> l . release ( ) ; <END_BUG> } Thread . sleep ( sleepTimeMS ) ; } } }

Fix:
l . close ( ) ;