From a2293ed9a883bad70612772277973e95a5a5f3e5 Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Tue, 13 Nov 2012 13:16:20 +0200 Subject: [PATCH] fix a bug related to plugin dependency --- .../pf4j/DefaultPluginDescriptorFinder.java | 2 +- .../ro/fortsoft/pf4j/PluginDescriptor.java | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java index 3cb6712..201ebb1 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java @@ -86,6 +86,6 @@ public class DefaultPluginDescriptorFinder implements PluginDescriptorFinder { } private boolean isEmpty(String value) { - return (value != null) && !value.isEmpty(); + return (value == null) || value.isEmpty(); } } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java index aba2fac..e6006d2 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java @@ -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(); - List 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(); + 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();