[
https://issues.apache.org/jira/browse/NIFI-1434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15114253#comment-15114253
]
ASF GitHub Bot commented on NIFI-1434:
--------------------------------------
GitHub user rpmiskin opened a pull request:
https://github.com/apache/nifi/pull/187
NIFI-1434 Prevent array index exception in PutEmail
I've updated PutEmail to avoid an ArrayIndexOutOfBoundsException in the
case where the FROM property evaluates to an empty string.
Reading through code in MimeMessage, message.addFrom(InternetAddress[]) is
equivalent to message.setFrom(String) in the case where the array has length 1
and will clear the sender when the array has length 0 (rather than throwing an
exception).
I have not made any changes to TestPutEmail. To provide more complete
testing I think it would be necessary to do a little refactoring to allow the
static call to Transport.send() to be stubbed. Possibly introducing a
PutEmail.send() method that would be overridden when testing?
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rpmiskin/nifi NIFI-1434
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/187.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 #187
----
commit 95c80b433056bd161c5ed64fa24186ac8b46485c
Author: Richard Miskin <[email protected]>
Date: 2016-01-24T09:07:57Z
NIFI-1434 Prevent array index exception in PutEmail
----
> ArrayIndexOutOfBoundsException in PutEmail if property expansion fails for
> PutEmail.FROM
> ----------------------------------------------------------------------------------------
>
> Key: NIFI-1434
> URL: https://issues.apache.org/jira/browse/NIFI-1434
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 0.4.1
> Reporter: Richard Miskin
>
> If the FROM property in PutEmail evaluates to an empty string an
> ArrayIndexOutOfBoundsException is thrown from the following code:
> {code:java}
> message.setFrom(InternetAddress.parse(context.getProperty(FROM)
> .evaluateAttributeExpressions(flowFile).getValue())[0]);
> {code}
> This leads to the FlowFile not being transferred to the REL_FAILURE
> relationship and the exception propagates out of the onTrigger method.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)