activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: fix stop/stop or stop no start NPE on sharedfilelocker
Date Tue, 20 Oct 2015 12:03:46 GMT
Repository: activemq
Updated Branches:
  refs/heads/master dc19d28af -> a01578ad4


fix stop/stop or stop no start NPE on sharedfilelocker


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/a01578ad
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/a01578ad
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/a01578ad

Branch: refs/heads/master
Commit: a01578ad4c93da5b28b76a9ef534394e5dcbb887
Parents: dc19d28
Author: gtully <gary.tully@gmail.com>
Authored: Tue Oct 20 13:02:57 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Tue Oct 20 13:02:57 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/activemq/store/SharedFileLocker.java | 6 ++++--
 .../java/org/apache/activemq/store/SharedFileLockerTest.java  | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/a01578ad/activemq-broker/src/main/java/org/apache/activemq/store/SharedFileLocker.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/store/SharedFileLocker.java
b/activemq-broker/src/main/java/org/apache/activemq/store/SharedFileLocker.java
index 56e7bde..025510b 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/store/SharedFileLocker.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/store/SharedFileLocker.java
@@ -99,8 +99,10 @@ public class SharedFileLocker extends AbstractLocker {
 
     @Override
     public void doStop(ServiceStopper stopper) throws Exception {
-        lockFile.unlock();
-        lockFile=null;
+        if (lockFile != null) {
+            lockFile.unlock();
+            lockFile = null;
+        }
     }
 
     public File getDirectory() {

http://git-wip-us.apache.org/repos/asf/activemq/blob/a01578ad/activemq-unit-tests/src/test/java/org/apache/activemq/store/SharedFileLockerTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/SharedFileLockerTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/SharedFileLockerTest.java
index 0c98b46..ac8b86e 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/SharedFileLockerTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/SharedFileLockerTest.java
@@ -60,6 +60,13 @@ public class SharedFileLockerTest {
     }
 
     @Test
+    public void testStopNoStart() throws Exception {
+        SharedFileLocker locker1 = new SharedFileLocker();
+        locker1.setDirectory(testFolder.getRoot());
+        locker1.stop();
+    }
+
+    @Test
     public void testLoop() throws Exception {
         // Increase the number of iterations if you are debugging races
         for (int i = 0; i < 100; i++) {


Mime
View raw message