diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtil.java index c5867143..d88ff826 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtil.java @@ -320,8 +320,7 @@ public abstract File downloadArtifact(String groupId, String artifactId, String * @param collections a collection of strings * @return the combined set of strings, ignoring case */ - @SafeVarargs - public static Set combineToSet(Collection... collections) { + public Set combineToSet(Collection... collections) { Set result = new HashSet(); Set lowercaseSet = new HashSet(); for (Collection collection : collections) { @@ -329,7 +328,12 @@ public static Set combineToSet(Collection... collections) { for (String value : collection) { if (!lowercaseSet.contains(value.toLowerCase())) { lowercaseSet.add(value.toLowerCase()); - result.add(value); + // if the value is empty or blank, issue a warning and do not add it to the list of features to install + if (value.isEmpty() || value.trim().isEmpty()) { + warn("An empty feature was specified in a server configuration file. Ensure that the features are valid."); + } else { + result.add(value); + } } } } diff --git a/src/test/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtilTest.java b/src/test/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtilTest.java index 21ecb2b0..24602c52 100644 --- a/src/test/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtilTest.java +++ b/src/test/java/io/openliberty/tools/common/plugins/util/InstallFeatureUtilTest.java @@ -97,6 +97,7 @@ public void testInstallFeatures() throws Exception { @Test public void testCombineToSet() throws Exception { + InstallFeatureUtil util = getNewInstallFeatureUtil(); Set a = new HashSet(); a.add("1"); a.add("2"); @@ -106,12 +107,13 @@ public void testCombineToSet() throws Exception { List c = new ArrayList(); c.add("4"); c.add("5"); - Set result = InstallFeatureUtil.combineToSet(a, b, c); + Set result = util.combineToSet(a, b, c); assertEquals(5, result.size()); } @Test public void testCombineToSetCaseInsensitive() throws Exception { + InstallFeatureUtil util = getNewInstallFeatureUtil(); Set a = new HashSet(); a.add("mpconfig-1.3"); a.add("mpOpenAPI-1.0"); @@ -125,7 +127,7 @@ public void testCombineToSetCaseInsensitive() throws Exception { c.add("mpHealth-1.0"); c.add("ejblite-3.2"); c.add("EJBLITE-3.2"); - Set result = InstallFeatureUtil.combineToSet(a, b, c); + Set result = util.combineToSet(a, b, c); assertEquals(5, result.size()); assertTrue(result.contains("mpconfig-1.3")); assertTrue(result.contains("mpOpenAPI-1.0"));