Github user YolandaMDavis commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/907#discussion_r75727555
  
    --- Diff: 
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/classloader/ClassLoaderUtils.java
 ---
    @@ -21,45 +21,59 @@
     import java.net.MalformedURLException;
     import java.net.URL;
     import java.net.URLClassLoader;
    +import java.util.Arrays;
     import java.util.LinkedList;
     import java.util.List;
    +import java.util.stream.Collectors;
     
     public class ClassLoaderUtils {
     
         public static ClassLoader getCustomClassLoader(String modulePath, 
ClassLoader parentClassLoader, FilenameFilter filenameFilter) throws 
MalformedURLException {
    -        String[] modules = modulePath != null? modulePath.split(",") : 
null;
    -        URL[] classpaths = getURLsForClasspath(modules,filenameFilter);
    -        return createModuleClassLoader(classpaths,parentClassLoader);
    +        // Split and trim the module path(s)
    +        List<String> modules = (modulePath == null)
    +                ? null
    +                : Arrays.stream(modulePath.split(",")).map((path) -> path 
== null ? null : path.trim()).filter((item) -> item != 
null).collect(Collectors.toList());
    --- End diff --
    
    Executed tests and realized doesn't quite cover for mistakenly added 
leading commas or leading/trailing commas with blanks before or after them 
(respectively) e.g. "/src/folder/one.jar1, /src/folder/two.jar, " . Edge case 
but I think changing the lambda around to blank values in array are filtered 
out should prevent error:
    
    //Maybe something like this using StringUtils.isNotBlank ?
    Arrays.stream(modulePath.split(",")).filter((item) -> 
StringUtils.isNotBlank(item)).map((path) -> 
path.trim()).collect(Collectors.toList());


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to