[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-28 Thread Benjamin Wood (JIRA)

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

Benjamin Wood commented on NIFI-4326:
-

Patch needs work, because of the newly discovered issue with getRecipients()

Will continue to iterate on patch-test until a workable solution is found.

The contract states that it will collect data "if available", meaning it should 
accept messages with no addressee or lists containing empty addresses.

> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-28 Thread Benjamin Wood (JIRA)

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

Benjamin Wood commented on NIFI-4326:
-

Using grepcode as a reference, should be able to substitute "getRecipients" 
with "getHeaderAsInternetAddresses" and pass it a "non-strict" address 
parameter. Because getRecipients just calls the other function under the hood.

Will do some rewrites of the processor and see if the exception is ignored in 
the "non-strict" parsing of mail addresses.

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.geronimo.specs/geronimo-javamail_1.4_spec/1.1/javax/mail/internet/MimeMessage.java#MimeMessage.getHeaderAsInternetAddresses%28java.lang.String%2Cboolean%29

> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-30 Thread Benjamin Wood (JIRA)

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

Benjamin Wood commented on NIFI-4326:
-

Working on adding weak address validation. Address validation is currently 
strict, and any violating address will stop the rest of the headers from being 
extracted.

Presumably this processor should handle the same messages that postfix or other 
mail servers would accept.

> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Whoops, didn't see this (or the corresponding JIRA) until after I opened a 
ticket and PR for the same issue 
([NIFI-4339](https://issues.apache.org/jira/browse/NIFI-4339), [PR 
2118](https://github.com/apache/nifi/pull/2118)) after it showed up on 
[StackOverflow](https://stackoverflow.com/questions/45927852/nifi-email-consumeimap-filter-by-subject-from-to-and-date/45928680#comment78898203_45928680).
 Looks like I accidentally duplicated your effort @btwood, my apologies. I was 
able to come up with a test case for the issue, see my branch if interested.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on the issue:

https://github.com/apache/nifi/pull/2111
  
@kevdoran No worries. I've actually been working on this for a while. I 
have a solution for both the NullPointerException, and also a problem I was 
having in my own production environment with strict email addresses. I've all 
but committed the code at this point.

I'll be making a commit very soon, and you can see if my fork solves your 
problem.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on the issue:

https://github.com/apache/nifi/pull/2111
  
@kevdoran The patch is in. I'll see if I can get it committed to mainline. 
Let me know if this solves your issue. I noticed you made some changes to a few 
other files in your PR. So I'm not sure if this operates the same way.

I didn't make any changes to the jUnit tests, and I'm not sure I need to. I 
guess I could add "non-strict" addresses in the CC field or something...


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
@btwood Thanks! 

I think they are close enough that I still consider them duplicates -- or 
more precisely, my patch is a subset of the issues yours addresses, as you have 
also added handling for non-strict addresses. Your changes should fix the case 
reported on StackOverflow, which is what my PR was intended to solve, but as I 
don't have access to that data the OP on SO will have to verify. I've 
encouraged that in a comment there.

I think the best thing to do is for me to close my current PR and instead 
submit a patch to your branch that adds my unit test case. Would you be open to 
that?


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Yes. We can definitely do that. Once you submit to my brand I'll 
review/accept the changes.

Side note, how can I make myself the "Assignee" in JIRA? I can't seem to 
make any updates that I'm doing the work, or that the work is complete (or 
almost complete).


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136450708
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

I don't think we should combine the values of the Sender and From headers 
here, for two reasons: 

1. It breaks the documentation for the processor that states 
email.headers.from will contain the values in From
2. If From is a mailbox-list, Sender might be a single mailbox in the From 
mailbox-list, so the result here could be a duplicate email address.

I think this could break expectations from folks already using the 
Extract

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136448958
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailAttachments.java
 ---
@@ -131,11 +132,15 @@ public void process(final InputStream rawIn) throws 
IOException {
 MimeMessageParser parser = new 
MimeMessageParser(originalMessage).parse();
 // RFC-2822 determines that a message must have a 
"From:" header
 // if a message lacks the field, it is flagged as 
invalid
-Address[] from = originalMessage.getFrom();
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false) == 
null) {
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false) 
== null) {
--- End diff --

Do you think falling back to "Sender" if "From" is not present for RFC 
validation is desired behavior? According to RFC-2882, and the RFCs that update 
it ([RFC-5322](https://tools.ietf.org/html/rfc5322), 
[RFC-6854](https://tools.ietf.org/html/rfc6854)), the "Sender" field should 
only be present if "From" is also present.

That said, @btwood, have you encountered email servers that use "Sender" 
without "From"? If so, it might be worth considering adjusting the 
implementation here to reflect what is likely to be encountered in the wild vs. 
strict RFC specification.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-08-31 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Oh, and to get the permissions for assigning yourself tickets on the NiFi 
JIRA, [subscribe to the dev mailing 
list](https://nifi.apache.org/mailing_lists.html) and send the dev list an 
email requesting that. Someone with sufficient permissions will modify your 
account. Pretty good NiFi discussions take place on that list.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136565224
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailAttachments.java
 ---
@@ -131,11 +132,15 @@ public void process(final InputStream rawIn) throws 
IOException {
 MimeMessageParser parser = new 
MimeMessageParser(originalMessage).parse();
 // RFC-2822 determines that a message must have a 
"From:" header
 // if a message lacks the field, it is flagged as 
invalid
-Address[] from = originalMessage.getFrom();
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false) == 
null) {
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false) 
== null) {
--- End diff --

I have a large corpus of mail to search for that. I can search for messages 
with a "Sender" header. The reason I did this however was to try and mimic 
"getFrom()" but without using the "strict" setting. So this is basically does 
the same thing getFrom() does, manually.

I was using the following grepcode for a closer look:

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.geronimo.specs/geronimo-javamail_1.4_spec/1.1/javax/mail/internet/MimeMessage.java#MimeMessage.getFrom%28%29

I guess the caveat there is that geronimo-javamail may be different 
implementation than openJDK javamail.

The mail server may not be the one setting the From/Sender header. That is 
often decided by the client. I suppose a sufficiently old mail client might set 
Sender instead. My understanding from the code is that they were synonymous. 
I'll re-read the RFC to see if that is the case.



> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136566431
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

My logic here was that I wanted ALL of the From/Sender addresses. So 
mailbox-list or not, in sender or not, this would collect them all. Note that 
I'm merging them. So if they are both present, then they will both be added.

Again, I'll have to re-read the RFC to see if this is correct. Based on the 
implementation of getFrom() I found on grepcode though, I figured it was. 

Perhaps a bad assumption though, because having read [RFC 
8

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136568496
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

I do have an example of a from address that was previously rejected and 
postfix accepted. It looked like this:

From: Automated System <>


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136571161
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

Thanks @btwood. I'll look into the getFrom() implementation. I didn't think 
of that, but you're right that the best thing to do would try to match that 
implementation as closely as possible as that is what was being called before. 

I thought about non-strict parsing more this morning. Would it be possible 
to make strict vs. non-strict parsing a user configurable toggle in the 
processor configuration? If so, and if the default was strict 

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136571436
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailAttachments.java
 ---
@@ -131,11 +132,15 @@ public void process(final InputStream rawIn) throws 
IOException {
 MimeMessageParser parser = new 
MimeMessageParser(originalMessage).parse();
 // RFC-2822 determines that a message must have a 
"From:" header
 // if a message lacks the field, it is flagged as 
invalid
-Address[] from = originalMessage.getFrom();
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false) == 
null) {
+if 
(InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false) 
== null) {
--- End diff --

See my comment below. I'm fine with matching what getFrom was doing. I'll 
take a look at that.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
>Reporter: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException
> It's possible this is only an issue with Oracle Java.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136572476
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

It absolutely would be possible. Instead of setting it manually to "false", 
we just need a variable set by the processor config. And pass that to 
getHeader(header, strict). I'm not certain how to accomplish that yet, but I'll 
look into it.

My day job is catching up with me today. I don't have free cycles at work 
at the moment that allow me to work on this. I will be free later this 
afternoon though.


> ExtractEmailHeaders.java unhandled 

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136572746
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

Cool, no rush. I've got other things to work on today as well. Will get 
back to this sometime over the weekend or next week. 


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-01 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r136573254
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -168,21 +173,40 @@ public void process(final InputStream rawIn) throws 
IOException {
 }
 }
 }
-if 
(Array.getLength(originalMessage.getAllRecipients()) > 0) {
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.TO)); 
toCount++) {
-attributes.put(EMAIL_HEADER_TO + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.TO)[toCount].toString());
+
+// Get Non-Strict Recipient Addresses
+InternetAddress[] recipients;
+if 
(originalMessage.getHeader(Message.RecipientType.TO.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.TO.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_TO + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.BCC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.BCC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.BCC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.BCC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_BCC + "." + 
toCount, recipients[toCount].toString());
 }
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getRecipients(Message.RecipientType.CC)); 
toCount++) {
-attributes.put(EMAIL_HEADER_CC + "." + 
toCount, 
originalMessage.getRecipients(Message.RecipientType.CC)[toCount].toString());
+}
+if 
(originalMessage.getHeader(Message.RecipientType.CC.toString(), ",") != null) {
+recipients = 
InternetAddress.parseHeader(originalMessage.getHeader(Message.RecipientType.CC.toString(),
 ","), false);
+for (int toCount = 0; toCount < 
ArrayUtils.getLength(recipients); toCount++) {
+attributes.put(EMAIL_HEADER_CC + "." + 
toCount, recipients[toCount].toString());
 }
 }
-// Incredibly enough RFC-2822 specified From as a 
"mailbox-list" so an array I returned by getFrom
-for (int toCount = 0; toCount < 
ArrayUtils.getLength(originalMessage.getFrom()); toCount++) {
-attributes.put(EMAIL_HEADER_FROM + "." + toCount, 
originalMessage.getFrom()[toCount].toString());
+
+// Get Non-Strict Sender Addresses
+InternetAddress[] sender = null;
+if (originalMessage.getHeader("From",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("From", ","), false));
+}
+if (originalMessage.getHeader("Sender",",") != null) {
+sender = 
(InternetAddress[])ArrayUtils.addAll(sender, 
InternetAddress.parseHeader(originalMessage.getHeader("Sender", ","), false));
--- End diff --

Also, I agree. We don't want to break anything for current users. If the 
expected behavior changes, we don't know how that impacts current users, 
because some may be relying on this to fail.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: B

[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-06 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Alright. Two new commits for each processor. The strict addressing setting 
is now a property configurable through the GUI. The default setting is "true" 
because that was the behavior prior to this patch.

Please review it and we can see if anything else needs to be done. I'm 
feeling pretty good about where this is now.

@kevdoran Do you still need to get the test code added?


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-11 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Hi @btwood, I'm checking the updated branch out now. Will let you know soon!


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-11 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Ok, I opened a PR to your branch. Take a look and let me know if you see 
anything else that needs to be done or if this is ready. Looks good on my end.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-14 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood closed the pull request at:

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


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-14 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on the issue:

https://github.com/apache/nifi/pull/2111
  
This is done.

This PR does the following:
- Handles the Null Pointer Exception when parsing email addresses (lack of 
address will not cause the Processors to fail)
- Adds the "Use Strict Address Parsing" Property to the ExtractEmailHeaders 
Processor to allow the user to tune the strictness of email address parsing
- Relaxes the strict email address requirement on the 
ExtractEmailAttachments Processor (from email doesn't need to be valid and is 
not used in the internal logic of the Processor)
- Adds unit tests for non-strict address parsing
- Fixes GennerateAttachment.java to return the correct value

Submitting this for review and merge.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-14 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

GitHub user btwood reopened a pull request:

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

NIFI-4326 - ExtractEmailHeaders.java unhandled NullPointerException

Resolve a null pointer exception when there is no recipient available in a 
TO, CC, or BCC header field.

No JIRA, although I did pull and build and test this change. It fixes the 
previously broken case.

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

$ git pull https://github.com/btwood/nifi patch-1

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

https://github.com/apache/nifi/pull/2111.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 #2111


commit afec1a35d9c36a4fc35f3a23d7c781c3853ba9a7
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-08-25T20:37:50Z

Update ExtractEmailHeaders.java

Resolve a null pointer exception when there is no recipient available in a 
TO, CC, or BCC header field.

commit 47f0fd8cf2fc005b4d71ba4764fde4fa2ec10d4f
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-08-31T19:10:13Z

NIFI-4326 Fix strict address parsing in ExtractEmailAttachments.java

This uses getHeader() instead of getFrom() in order to avoid strict 
addressing. 
This matches changes to ExtractEmailHeaders.java

Postfix and other mail servers are much more linient in accepting 
addresses. Using strict = false from getHeaders() we can accept more addresses 
that otherwise would be rejected.

commit 437e9b627f4976ca7587d21b7c7da97a0dc5f371
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-08-31T19:11:16Z

NIFI-4326 Fix NullPointerException and strict addressing

This uses parseHeader() instead of getFrom() and getRecipients() in order 
to avoid strict addressing.
It also checks for null to solve a null pointer exception.
By contract, this processor should grab information "if available". Which 
means it should not fail if the info is unavailable.

commit 4380b4deacbf00a324085a55085e33e858318073
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-09-06T20:24:18Z

NIFI-4326 Added property for strict addresses 

Added a property and corresponding variable for setting strict addressing. 
The default is ON so as not to impact current users relying on the processor to 
reject weakly addressed email.

commit ccfb2ee3c2725801978d9de0402a2e4656686920
Author: Kevin Doran 
Date:   2017-09-11T17:24:47Z

NIFI-4326: Add unit test cases

commit 2ad69672602f76fb09a083c96adf74dc3c868240
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-09-13T13:53:42Z

Merge pull request #1 from kevdoran/NIFI-4326-extract-email-headers

NIFI-4326: Add unit test cases, clean up code, correct processor 
documentation

commit 8308cabb9cb5a2a9984d03817d3882e85a046fe2
Author: btwood <4839861+btw...@users.noreply.github.com>
Date:   2017-09-13T21:53:40Z

NIFI-4326 Add non-strict email address parsing

Added mailSession properties for non-strict address parsing to mirror what 
was done in the ExtractEmailHeaders.java

This relaxes the requirement for valid email addresses. Email addresses are 
not used in this processor and has no impact on extracting attachments. In 
order to process more emails and extract more attachments, the 
mail.mime.address.strict property was set to false. This was done with a 
variable in order to make it easier to add a property to the processor later if 
desired.




> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-19 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r139724038
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -103,6 +102,21 @@
 .defaultValue("x-mailer")
 .build();
 
+private static final String STRICT_ADDRESSING_DEFAULT_VALUE = "true";
+public static final PropertyDescriptor STRICT_ADDRESSING = new 
PropertyDescriptor.Builder()
+.name("STRICT_ADDRESS_PARSING")
+.displayName("Use Strict Address Parsing")
+.description("If true, strict address format parsing rules are 
applied to mailbox and mailbox list fields, " +
+"such as \"to\" and \"from\" headers, and FlowFiles 
with poorly formed addresses will be routed " +
+"to the failure relationship, similar to messages that 
fail RFC compliant format validation. " +
+"If false, the processor will extract the contents of 
mailbox list headers as comma-separated " +
+"values without attempting to parse each value as 
well-formed Internet mailbox addresses. " +
+"This is optional and defaults to " + 
STRICT_ADDRESSING_DEFAULT_VALUE)
+.required(false)
+.defaultValue(STRICT_ADDRESSING_DEFAULT_VALUE)
+.allowableValues("true", "false")
--- End diff --

I would change this to use the "AllowableValue" class and move some of the 
description of "true" vs. "false" behavior from the description field into each 
value. Here is an example: 
https://github.com/apache/nifi/pull/2148/files#diff-4f399a5e493f124a256ae2740c20f839
 


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-19 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r139775788
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -103,6 +102,21 @@
 .defaultValue("x-mailer")
 .build();
 
+private static final String STRICT_ADDRESSING_DEFAULT_VALUE = "true";
+public static final PropertyDescriptor STRICT_ADDRESSING = new 
PropertyDescriptor.Builder()
+.name("STRICT_ADDRESS_PARSING")
+.displayName("Use Strict Address Parsing")
+.description("If true, strict address format parsing rules are 
applied to mailbox and mailbox list fields, " +
+"such as \"to\" and \"from\" headers, and FlowFiles 
with poorly formed addresses will be routed " +
+"to the failure relationship, similar to messages that 
fail RFC compliant format validation. " +
+"If false, the processor will extract the contents of 
mailbox list headers as comma-separated " +
+"values without attempting to parse each value as 
well-formed Internet mailbox addresses. " +
+"This is optional and defaults to " + 
STRICT_ADDRESSING_DEFAULT_VALUE)
+.required(false)
+.defaultValue(STRICT_ADDRESSING_DEFAULT_VALUE)
+.allowableValues("true", "false")
--- End diff --

Sorry forgot about that. I had the "office plague" (flu) last week. I'll 
commit again very soon, and you can re-review.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-19 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r139775977
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -103,6 +102,21 @@
 .defaultValue("x-mailer")
 .build();
 
+private static final String STRICT_ADDRESSING_DEFAULT_VALUE = "true";
+public static final PropertyDescriptor STRICT_ADDRESSING = new 
PropertyDescriptor.Builder()
+.name("STRICT_ADDRESS_PARSING")
+.displayName("Use Strict Address Parsing")
+.description("If true, strict address format parsing rules are 
applied to mailbox and mailbox list fields, " +
+"such as \"to\" and \"from\" headers, and FlowFiles 
with poorly formed addresses will be routed " +
+"to the failure relationship, similar to messages that 
fail RFC compliant format validation. " +
+"If false, the processor will extract the contents of 
mailbox list headers as comma-separated " +
+"values without attempting to parse each value as 
well-formed Internet mailbox addresses. " +
+"This is optional and defaults to " + 
STRICT_ADDRESSING_DEFAULT_VALUE)
+.required(false)
+.defaultValue(STRICT_ADDRESSING_DEFAULT_VALUE)
+.allowableValues("true", "false")
--- End diff --

No worries! Will do, thanks!


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r139978847
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -103,6 +103,22 @@
 .defaultValue("x-mailer")
 .build();
 
+private static final AllowableValue STRICT_ADDRESSING = new 
AllowableValue("true", "Strict Address Parsing", "Strict email address format 
will be enforced. FlowFiles will be transfered to the failure relationship if 
the email address is invalid.");
--- End diff --

Just ran a build with -Pcontrib-check, and these two lines are failing the 
style guide due to length (max line width is 200 columns).

@btwood can you fix?


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-20 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user btwood commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2111#discussion_r140057900
  
--- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ExtractEmailHeaders.java
 ---
@@ -103,6 +103,22 @@
 .defaultValue("x-mailer")
 .build();
 
+private static final AllowableValue STRICT_ADDRESSING = new 
AllowableValue("true", "Strict Address Parsing", "Strict email address format 
will be enforced. FlowFiles will be transfered to the failure relationship if 
the email address is invalid.");
--- End diff --

@kevdoran I've committed the fix. I didn't know about the -Pcontrib-check 
build. I added that to my build config and got it to pass. Should be good now. 
Thanks.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-21 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user kevdoran commented on the issue:

https://github.com/apache/nifi/pull/2111
  
Thanks, build is passing on my machine as well.

+1, LGTM


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-21 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user asfgit closed the pull request at:

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


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-21 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on NIFI-4326:
--

Github user pvillard31 commented on the issue:

https://github.com/apache/nifi/pull/2111
  
+1, build with contrib-check OK, code LGTM. Merging to master. Thanks for 
the work and review @btwood @kevdoran !


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions

2017-09-21 Thread ASF subversion and git services (JIRA)

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

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

Commit 90ed08ec338d014d6ed5ae6ab2b14f230ccd724a in nifi's branch 
refs/heads/master from btwood
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=90ed08e ]

NIFI-4326 Fix NullPointerException and strict addressing

This uses parseHeader() instead of getFrom() and getRecipients() in order to 
avoid strict addressing.
It also checks for null to solve a null pointer exception.
By contract, this processor should grab information "if available". Which means 
it should not fail if the info is unavailable.

Signed-off-by: Pierre Villard 

This closes #2111.


> ExtractEmailHeaders.java unhandled Exceptions
> -
>
> Key: NIFI-4326
> URL: https://issues.apache.org/jira/browse/NIFI-4326
> Project: Apache NiFi
>  Issue Type: Bug
>  Components: Core Framework
>Affects Versions: 1.3.0
> Environment: jdk 1.8.0_121-b13
> openjdk 8u131-b11
>Reporter: Benjamin Wood
>Assignee: Benjamin Wood
>Priority: Minor
> Fix For: 1.4.0
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The ExtractEmailHeaders  processor throws a NullPointerException if there is 
> no TO, CC, and BCC recipients.
> If there are no recipients "originalMessage.getAllRecipients()" returns NULL, 
> and not a 0 length array.
> If an address is empty (<> or " ") then getRecipients() will throw an "Empty 
> Address" AddressException



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)