@@ -93,6 +93,7 @@ protected static class FDBDirectoryLock extends Lock {
9393 private FDBRecordContext closingContext = null ;
9494 private final Object fileLockSetLock = new Object ();
9595 private boolean clearingLockNow = false ;
96+ private final Object clearingLockNowLock = new Object ();
9697
9798 private FDBDirectoryLock (final AgilityContext agilityContext , final String lockName , byte [] fileLockKey , int timeWindowMilliseconds ) {
9899 this .agilityContext = agilityContext ;
@@ -210,18 +211,13 @@ private void fileLockCheckNewLock(byte[] val, long nowMillis) {
210211 }
211212 }
212213
213- private synchronized boolean inRecursiveClearLock () {
214- if (clearingLockNow ) {
215- return true ;
216- }
217- clearingLockNow = true ;
218- return false ;
219- }
220-
221214 private void fileLockClearFlushAndClose (boolean isRecovery ) {
222- if ( inRecursiveClearLock () ) {
215+ synchronized ( clearingLockNowLock ) {
223216 // Here: this function is being called from too many paths. Until cleanup, this guard is here to avoid recursions
224- return ;
217+ if (clearingLockNow ) {
218+ return ;
219+ }
220+ clearingLockNow = true ;
225221 }
226222 Function <FDBRecordContext , CompletableFuture <Void >> fileLockFunc = aContext ->
227223 aContext .ensureActive ().get (fileLockKey )
@@ -257,7 +253,10 @@ private void fileLockClearFlushAndClose(boolean isRecovery) {
257253 } finally {
258254 closed = flushed ; // allow close retry
259255 closingContext = null ;
260- clearingLockNow = false ;
256+ synchronized (clearingLockNowLock ) {
257+ // clearing under lock to avoid spotbugsMain's "Inconsistent synchronization" issue.
258+ clearingLockNow = false ;
259+ }
261260 }
262261 }
263262
0 commit comments