fix stop/stop or stop no start NPE on sharedfilelocker

This commit is contained in:
gtully 2015-10-20 13:02:57 +01:00
parent dc19d28af9
commit a01578ad4c
2 changed files with 11 additions and 2 deletions

View File

@ -99,8 +99,10 @@ public class SharedFileLocker extends AbstractLocker {
@Override @Override
public void doStop(ServiceStopper stopper) throws Exception { public void doStop(ServiceStopper stopper) throws Exception {
lockFile.unlock(); if (lockFile != null) {
lockFile=null; lockFile.unlock();
lockFile = null;
}
} }
public File getDirectory() { public File getDirectory() {

View File

@ -59,6 +59,13 @@ public class SharedFileLockerTest {
} }
@Test
public void testStopNoStart() throws Exception {
SharedFileLocker locker1 = new SharedFileLocker();
locker1.setDirectory(testFolder.getRoot());
locker1.stop();
}
@Test @Test
public void testLoop() throws Exception { public void testLoop() throws Exception {
// Increase the number of iterations if you are debugging races // Increase the number of iterations if you are debugging races