]> source.dussan.org Git - pf4j.git/commitdiff
fix a bug related to plugin dependency
authorDecebal Suiu <decebal.suiu@gmail.com>
Tue, 13 Nov 2012 11:16:20 +0000 (13:16 +0200)
committerDecebal Suiu <decebal.suiu@gmail.com>
Tue, 13 Nov 2012 11:16:20 +0000 (13:16 +0200)
pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java
pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java

index 3cb6712ffc59fdfbfedc5a6fa4d81a5a497e7e7b..201ebb11d79debf15b3a6dedaf41583438e567c3 100644 (file)
@@ -86,6 +86,6 @@ public class DefaultPluginDescriptorFinder implements PluginDescriptorFinder {
        }
     
        private boolean isEmpty(String value) {
-               return (value != null) && !value.isEmpty();
+               return (value == null) || value.isEmpty();
        }
 }
index aba2fac71f319f9f5ef8f8e83c901bf63841315d..e6006d27db6a85d0a9c28a059d46280c9792512f 100644 (file)
@@ -13,7 +13,6 @@
 package ro.fortsoft.pf4j;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -107,10 +106,21 @@ public class PluginDescriptor {
     
     void setDependencies(String dependencies) {
        if (dependencies != null) {
-               this.dependencies = new ArrayList<PluginDependency>();
-               List<String> tokens = Arrays.asList(dependencies.split(","));
-               for (String dependency : tokens) {
-                       this.dependencies.add(new PluginDependency(dependency));
+               dependencies = dependencies.trim();
+               if (dependencies.isEmpty()) {
+                       this.dependencies = Collections.emptyList();
+               } else {
+                       this.dependencies = new ArrayList<PluginDependency>();
+                       String[] tokens = dependencies.split(",");              
+                       for (String dependency : tokens) {
+                               dependency = dependency.trim();
+                               if (!dependency.isEmpty()) {
+                                       this.dependencies.add(new PluginDependency(dependency));
+                               }
+                       }
+                       if (this.dependencies.isEmpty()) {
+                               this.dependencies = Collections.emptyList();
+                       }
                }
        } else {
                this.dependencies = Collections.emptyList();