File tree Expand file tree Collapse file tree
main/java/org/janelia/saalfeldlab/n5
test/java/org/janelia/saalfeldlab/n5 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ private void releaseFileLock() {
173173
174174 void releaseLock () {
175175
176+ System .out .println ("KeyLockState.releaseLock" );
176177 final boolean isWrite = threadLock .isWriteLockedByCurrentThread ();
177178
178179 synchronized (this ) {
@@ -181,6 +182,7 @@ void releaseLock() {
181182 releaseFileLock ();
182183 } else {
183184 readLockHolders --;
185+ System .out .println (" readLockHolders = " + readLockHolders );
184186 if (readLockHolders == 0 ) {
185187 releaseFileLock ();
186188 }
Original file line number Diff line number Diff line change @@ -76,6 +76,33 @@ public void tearDown() throws IOException {
7676 }
7777 }
7878
79+ private void lockunlock (final Path testFile ) throws IOException {
80+ LockedChannel lock1 = FILE_LOCK_MANAGER .lockForReading (testFile );
81+ lock1 .close ();
82+ }
83+
84+ @ Test
85+ public void testCleanup () throws Exception {
86+ /* create a test file */
87+ final Path testFile = tempDir .resolve ("test.txt" );
88+ final String testContent = "test" ;
89+ Files .write (testFile , testContent .getBytes ());
90+
91+ LockedChannel lock1 = FILE_LOCK_MANAGER .lockForReading (testFile );
92+ LockedChannel lock2 = FILE_LOCK_MANAGER .lockForReading (testFile );
93+ System .out .println ("lock1.close" );
94+ lock1 .close ();
95+ lock1 = null ;
96+ for (int i = 0 ; i < 10 ; i ++) {
97+ System .out .println ("lockunlock" );
98+ lockunlock (testFile );
99+ System .gc ();
100+ Thread .sleep (500 );
101+ }
102+ System .out .println ("lock2.close" );
103+ lock2 .close ();
104+ }
105+
79106 @ Test
80107 public void testConcurrentReads () throws Exception {
81108
You can’t perform that action at this time.
0 commit comments