diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java index f1f4bce78..ea049f67c 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/folder/FolderObserver.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.WatchEvent; import java.nio.file.WatchEvent.Kind; +import java.util.Arrays; import java.util.Dictionary; import java.util.Enumeration; import java.util.HashMap; @@ -33,8 +34,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; import org.openhab.core.config.core.ConfigConstants; import org.openhab.core.model.core.ModelParser; import org.openhab.core.model.core.ModelRepository; @@ -109,7 +108,7 @@ public class FolderObserver extends AbstractWatchService { Enumeration keys = config.keys(); while (keys.hasMoreElements()) { String foldername = keys.nextElement(); - if (!StringUtils.isAlphanumeric(foldername)) { + if (!foldername.matches("[A-Za-z0-9_]*")) { // we allow only simple alphanumeric names for model folders - everything else might be other service // properties continue; @@ -263,15 +262,15 @@ public class FolderObserver extends AbstractWatchService { } private File getFileByFileExtMap(Map folderFileExtMap, String filename) { - if (StringUtils.isNotBlank(filename) && isNotEmpty(folderFileExtMap)) { + if (filename != null && !filename.trim().isEmpty() && isNotEmpty(folderFileExtMap)) { String extension = getExtension(filename); - if (StringUtils.isNotBlank(extension)) { + if (extension != null && !extension.trim().isEmpty()) { Set> entries = folderFileExtMap.entrySet(); Iterator> iterator = entries.iterator(); while (iterator.hasNext()) { Entry entry = iterator.next(); - if (ArrayUtils.contains(entry.getValue(), extension)) { + if (Arrays.stream(entry.getValue()).anyMatch(extension::equals)) { return new File(getFile(entry.getKey()) + File.separator + filename); } } diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/net/HttpServiceUtilTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/net/HttpServiceUtilTest.java index 74603e4a5..faf2637b4 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/net/HttpServiceUtilTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/net/HttpServiceUtilTest.java @@ -17,7 +17,9 @@ import static org.junit.Assert.assertThat; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; -import org.apache.commons.lang.ArrayUtils; +import java.util.Arrays; +import java.util.stream.Stream; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -46,7 +48,8 @@ public class HttpServiceUtilTest { ServiceReference[] secureHttpServiceReferences = getSecureHttpServiceReferences(); when(bundleContext.getAllServiceReferences(ORG_OSGI_SERVICE_HTTP_SERVICE, null)).thenReturn( - (ServiceReference[]) ArrayUtils.addAll(httpServiceReferences, secureHttpServiceReferences)); + Stream.concat(Arrays.stream(httpServiceReferences), Arrays.stream(secureHttpServiceReferences)) + .toArray(ServiceReference[]::new)); } @Test