[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-2619:
--

Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/907


> 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
> Fix For: 1.0.0
>
>
> 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF subversion and git services (JIRA)

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

ASF subversion and git services commented on NIFI-2619:
---

Commit 7123a1a2761d238b2d1e300e33f2f3ade54347e1 in nifi's branch 
refs/heads/master from [~mattyb149]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=7123a1a ]

NIFI-2619: Added unit test showing bugs, Added logic to ClassLoaderUtils to 
trim module paths and accept URLs

Signed-off-by: Yolanda M. Davis 

This closes #907


> 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-2619:
--

Github user YolandaMDavis commented on the issue:

https://github.com/apache/nifi/pull/907
  
@mattyb149 thanks for applying that change.  I tested on standalone node 
with Jolt Transform processor using a list of customjars (included extra 
commas, spaces etc) and works as expected with no exceptions thrown.

+1

Will squash and merge shortly


> 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/NIFI-2619?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-2619:
--

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 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());


> 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-2619:
--

Github user YolandaMDavis commented on the issue:

https://github.com/apache/nifi/pull/907
  
@mattyb149 will take a look


> 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)


[jira] [Commented] (NIFI-2619) ClassLoaderUtils doesn't support spaces between paths or URLs in the paths

2016-08-22 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-2619:
--

GitHub user mattyb149 opened a pull request:

https://github.com/apache/nifi/pull/907

NIFI-2619: Added logic to ClassLoaderUtils to trim module paths and accept 
URLs



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mattyb149/nifi NIFI-2619

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/907.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #907


commit 663ada18ff39deb261b6923c47f1f422b859e302
Author: Matt Burgess 
Date:   2016-08-22T15:09:14Z

NIFI-2619: Added unit test showing bugs

commit 623d41affe5e24142a2fd8a48d97e682e9245af7
Author: Matt Burgess 
Date:   2016-08-22T15:11:52Z

NIFI-2619: Added logic to ClassLoaderUtils to trim module paths and accept 
URLs




> 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)