diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/control/ControlDirectoryEventFeed.java b/common/source/java/ch/systemsx/cisd/common/filesystem/control/ControlDirectoryEventFeed.java index a522749588ca32cda68b9a09a6a217efc2275d3e..3dcdade78003988e247f6ee52d30c2be59ecd14d 100644 --- a/common/source/java/ch/systemsx/cisd/common/filesystem/control/ControlDirectoryEventFeed.java +++ b/common/source/java/ch/systemsx/cisd/common/filesystem/control/ControlDirectoryEventFeed.java @@ -43,6 +43,11 @@ public class ControlDirectoryEventFeed implements IEventFeed { List<String> events = new ArrayList<String>(); + if (controlDir.exists() == false || controlDir.isDirectory() == false) + { + return events; + } + List<File> files = Arrays.asList(controlDir.listFiles()); Collections.sort(files, new Comparator<File>() diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReader.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReader.java index b0b1cc71dabd847929e15d523654886743940087..9a23317fbee4204cf394deda2c20bde8b62a38d5 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReader.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReader.java @@ -18,8 +18,8 @@ package ch.systemsx.cisd.openbis.common.controlfile; import java.io.File; +import ch.systemsx.cisd.common.filesystem.control.ControlDirectoryEventFeed; import ch.systemsx.cisd.common.filesystem.control.DelayingDecorator; -import ch.systemsx.cisd.common.filesystem.control.FileSystemBasedEventProvider; import ch.systemsx.cisd.common.filesystem.control.IValueFilter; import ch.systemsx.cisd.common.filesystem.control.ParameterMap; @@ -49,7 +49,7 @@ public class ControlFileReader public ControlFileReader(File controlFileDirectory, long controlFileMaxDelay) { parameterMap = - new ParameterMap(new DelayingDecorator(controlFileMaxDelay, new FileSystemBasedEventProvider(controlFileDirectory))); + new ParameterMap(new DelayingDecorator(controlFileMaxDelay, new ControlDirectoryEventFeed(controlFileDirectory))); parameterMap.addParameter(LOG_SERVICE_CALL_START, OFF, new IValueFilter() { diff --git a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReaderTest.java b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReaderTest.java index 256d8ff23e4a0d723cc64e23d81375d660127c2f..a28801283c277ed7268ab5be7a856f9df68e655e 100644 --- a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReaderTest.java +++ b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/controlfile/ControlFileReaderTest.java @@ -47,7 +47,7 @@ public class ControlFileReaderTest } @Test - public void test() throws IOException + public void testSwitchOnAndOff() throws IOException { ControlFileReader reader = new ControlFileReader(getControlFileDirectory(), -1); Assert.assertFalse(reader.isLogServiceCallStartEnabled()); @@ -59,6 +59,19 @@ public class ControlFileReaderTest Assert.assertFalse(reader.isLogServiceCallStartEnabled()); } + @Test + public void testWithNotExistingControlFileDirectory() throws IOException + { + ControlFileReader reader = new ControlFileReader(new File(getControlFileDirectory(), "notExisting"), -1); + Assert.assertFalse(reader.isLogServiceCallStartEnabled()); + + new File(getControlFileDirectory(), "log-service-call-start-on").createNewFile(); + Assert.assertFalse(reader.isLogServiceCallStartEnabled()); + + new File(getControlFileDirectory(), "log-service-call-start-off").createNewFile(); + Assert.assertFalse(reader.isLogServiceCallStartEnabled()); + } + private File getControlFileDirectory() { TestResources resources = new TestResources(getClass());