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,9 +99,11 @@ public class SharedFileLocker extends AbstractLocker {
@Override
public void doStop(ServiceStopper stopper) throws Exception {
if (lockFile != null) {
lockFile.unlock();
lockFile = null;
}
}
public File getDirectory() {
return directory;

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
public void testLoop() throws Exception {
// Increase the number of iterations if you are debugging races