This is an automated email from the ASF dual-hosted git repository.

mattyb149 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new da593a2  Update WriteResourceToStream.java
da593a2 is described below

commit da593a2e8ebd3e2909c75999e4585991c6a2369c
Author: Alexander T <37665177+aleks...@users.noreply.github.com>
AuthorDate: Thu Mar 21 08:13:25 2019 +0100

    Update WriteResourceToStream.java
    
    Thread.currentThread().getContextClassLoader().getResourceAsStream(...) 
works in UnitTest, but not if the NAR is deployed in /extensions folder. If you 
want to use the processer the resource 'file.txt' is not found.
    I changed this to 'getClass().getClassLoader()...' and its working as 
UnitTest and when deployed
    
    Signed-off-by: Matthew Burgess <mattyb...@apache.org>
    
    This closes #3381
---
 .../main/java/org/apache/nifi/processors/WriteResourceToStream.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/nifi-external/nifi-example-bundle/nifi-nifi-example-processors/src/main/java/org/apache/nifi/processors/WriteResourceToStream.java
 
b/nifi-external/nifi-example-bundle/nifi-nifi-example-processors/src/main/java/org/apache/nifi/processors/WriteResourceToStream.java
index 1ce0974..cb5b888 100644
--- 
a/nifi-external/nifi-example-bundle/nifi-nifi-example-processors/src/main/java/org/apache/nifi/processors/WriteResourceToStream.java
+++ 
b/nifi-external/nifi-example-bundle/nifi-nifi-example-processors/src/main/java/org/apache/nifi/processors/WriteResourceToStream.java
@@ -58,8 +58,8 @@ public class WriteResourceToStream extends AbstractProcessor {
         relationships.add(REL_SUCCESS);
         relationships.add(REL_FAILURE);
         this.relationships = Collections.unmodifiableSet(relationships);
-        final InputStream resourceStream = Thread.currentThread()
-                .getContextClassLoader().getResourceAsStream("file.txt");
+        final InputStream resourceStream = getClass()
+                .getClassLoader().getResourceAsStream("file.txt");
         try {
             this.resourceData = IOUtils.toString(resourceStream, 
Charset.defaultCharset());
         } catch (IOException e) {

Reply via email to