Details
-
Bug
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
0.5.0, 0.4.1
-
None
Description
When Comannd Arguments property contains expression to be evaluated, the expression is taken as one command argument instead of being splitted using argument separator.
To reproduce the problem:
1. Create DataFlow
2. Add GenerateFlowFile processor, File Size: 10kB
3. Connect GenerateFlowFile -> success -> UpdateAttribute processor
4. In UpdateAttribute: create attribute optionalArgs with contents: "-c 5"
5. Connect UpdateAttribute -> success -> ExecuteStreamCommand
6. Configure ExecuteStreamCommand to execute Command Path: "ping", Command Arguments: "${optionalArgs} google.com", Argument Delimiter: " " (spacebar), Ignore STDIN: true, auto terminate: original
7. Connect ExecuteStreamCommand -> output stream - > LogAttribute to see some output. LogAttribute auto terminate: success, Log Level: error, Log Payload: true.
8. Run the flow.
Expected output:
1. ExecuteStreamCommand issues command ping with args:[ "-c", "5", "google.com"]
Actual output:
1. ExecuteStreamCommand puts the "-c 5" into single arg for ProcessBuilder. args: are ["-c 5", "google.com"]
This behavior is no problem for ping utility (as it reparses the commandline again to search for argument separator), but there are tools (like snmpwalk in my case), which are dumb enough not to parse command line arguments properly, when they are sent inproperly by ProcessBuilder.
The problem is apparently in lines: ExecuteStreamCommand.java: 305-306, where arguments splitting on argument separator is done before expression language evaluation. The fix should reverse the operation: first evaluate expression language and the split the arguments by separator.