[FELIX-4618] - NPE if config value for ignore topic or timeout is empty
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1620869 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/eventadmin/impl/changelog.txt b/eventadmin/impl/changelog.txt
index fe49877..8b2eab7 100644
--- a/eventadmin/impl/changelog.txt
+++ b/eventadmin/impl/changelog.txt
@@ -2,6 +2,7 @@
---------------------------
** Bug
* [FELIX-4617] - Empty configurations for ignore topic and ignore timeout lead to error messages in the log
+ * [FELIX-4618] - NPE if config value for ignore topic or timeout is empty
Changes from 1.3.2 to 1.4.0
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
index 077f32c..91f1eb0 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
@@ -18,6 +18,7 @@
*/
package org.apache.felix.eventadmin.impl.handler;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -283,7 +284,7 @@
}
else
{
- matchers = new Matcher[config.length];
+ final List<Matcher> list = new ArrayList<EventHandlerTracker.Matcher>();
for(int i=0;i<config.length;i++)
{
String value = config[i];
@@ -295,7 +296,7 @@
{
if ( value.endsWith(".") )
{
- matchers[i] = new PackageMatcher(value.substring(0, value.length() - 1));
+ list.add(new PackageMatcher(value.substring(0, value.length() - 1)));
}
else if ( value.endsWith("*") )
{
@@ -303,14 +304,22 @@
{
return new Matcher[] {new MatcherAll()};
}
- matchers[i] = new SubPackageMatcher(value.substring(0, value.length() - 1));
+ list.add(new SubPackageMatcher(value.substring(0, value.length() - 1)));
}
else
{
- matchers[i] = new ClassMatcher(value);
+ list.add(new ClassMatcher(value));
}
}
}
+ if ( list.size() > 0 )
+ {
+ matchers = list.toArray(new Matcher[list.size()]);
+ }
+ else
+ {
+ matchers = null;
+ }
}
return matchers;
}