You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2023/06/21 10:25:00 UTC

[jira] [Commented] (NIFI-7016) Correct Groovy File functions available for FlowFile in ExecuteGroovyScript

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

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

Commit 84fdb5e32ff1a96e36b36a314006d33e1f0aa913 in nifi's branch refs/heads/main from Matt Burgess
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=84fdb5e32f ]

NIFI-7016: Fix Groovy File functions available for FlowFile in ExecuteGroovyScript

This closes #7016

Signed-off-by: Mike Thomsen <mt...@apache.org>


> Correct Groovy File functions available for FlowFile in ExecuteGroovyScript
> ---------------------------------------------------------------------------
>
>                 Key: NIFI-7016
>                 URL: https://issues.apache.org/jira/browse/NIFI-7016
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Dmitry Lukyanov
>            Assignee: Matt Burgess
>            Priority: Minor
>             Fix For: 1.latest, 2.latest
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently the following methods implemented but they differ from groovy flavor.
> All those methods should return the object returned by Closure and streams/readers/writers must be closed after closure finished.
> Check any of this methods in groovy:
> http://docs.groovy-lang.org/latest/html/groovy-jdk/java/io/File.html#withOutputStream(groovy.lang.Closure)
> The idea of usage like this:
> {code:java}
> def jsonData = flowFile.withReader("UTF-8"){ new JsonSlurper().parse(it) }
> {code}
> methods to be fixed according to groovy behavior:
> {code:java}
> Object withInputStream(Closure closure)
> // Creates a new InputStream for this file and passes it into the closure.
> // Input stream must be closed after closure finished
> // Returns value returned by closure
> Object 	withOutputStream(Closure closure)
> // Creates a new OutputStream for this file and passes it into the closure. 
> // OutputStream must be closed after closure finished. 
> // Returns value returned by closure 
> Object 	withReader(String charset, Closure closure)
> // Creates a new BufferedReader for this file using the specified charset and then passes it into the closure, ensuring the reader is closed after the closure returns. 
> // Returns value returned by closure 
> Object 	withWriter(String charset, Closure closure)
> // Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. 
> // Returns value returned by closure 
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)