diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java index db4c838656..95b3f5e33a 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java @@ -229,7 +229,7 @@ public class MessageDatabase { lockFile.lock(); break; } catch (IOException e) { - LOG.info("Database "+lockFileName+" is locked... waiting " + (DATABASE_LOCKED_WAIT_DELAY / 1000) + " seconds for the database to be unlocked."); + LOG.info("Database "+lockFileName+" is locked... waiting " + (DATABASE_LOCKED_WAIT_DELAY / 1000) + " seconds for the database to be unlocked. Reason: " + e); try { Thread.sleep(DATABASE_LOCKED_WAIT_DELAY); } catch (InterruptedException e1) { diff --git a/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java b/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java index c7338565ea..1d7b5b6ba3 100644 --- a/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java +++ b/kahadb/src/main/java/org/apache/kahadb/util/LockFile.java @@ -50,8 +50,7 @@ public class LockFile { return; } - lockCounter++; - if( lockCounter!=1 ) { + if( lockCounter>0 ) { return; } @@ -63,9 +62,12 @@ public class LockFile { } catch (OverlappingFileLockException e) { throw IOExceptionSupport.create("File '" + file + "' could not be locked.",e); } - if (lock == null) { + if (lock != null) { + lockCounter++; + } else { throw new IOException("File '" + file + "' could not be locked."); } + } }