[ 
https://issues.apache.org/jira/browse/NIFI-2619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15431355#comment-15431355
 ] 

ASF GitHub Bot commented on NIFI-2619:
--------------------------------------

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

    https://github.com/apache/nifi/pull/907#discussion_r75730484
  
    --- 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 --
    
    Good point. I changed to use yours (replacing some things with method 
references) and added a unit test around the errors you found.


> ClassLoaderUtils doesn't support spaces between paths or URLs in the paths
> --------------------------------------------------------------------------
>
>                 Key: NIFI-2619
>                 URL: https://issues.apache.org/jira/browse/NIFI-2619
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Matt Burgess
>            Assignee: Matt Burgess
>
> ClassLoaderUtils.getCustomClassLoader() splits a module path list on a comma, 
> but doesn't trim the individual entries.
> Also in ClassLoaderUtils.getURLsForClasspath(), it is assumed that the paths 
> are Files, but they could also already be URLs. Logic should be added to 
> check if the path is already a valid URL, and add it to the list if so.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to