Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2D4042004F5 for ; Fri, 1 Sep 2017 15:24:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2BBFF16CFED; Fri, 1 Sep 2017 13:24:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4BB5216CFEA for ; Fri, 1 Sep 2017 15:24:08 +0200 (CEST) Received: (qmail 48501 invoked by uid 500); 1 Sep 2017 13:24:06 -0000 Mailing-List: contact issues-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list issues@nifi.apache.org Received: (qmail 48492 invoked by uid 99); 1 Sep 2017 13:24:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2017 13:24:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5CEFE1A28A2 for ; Fri, 1 Sep 2017 13:24:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id qz8cGZecf9sI for ; Fri, 1 Sep 2017 13:24:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id F278B5FD42 for ; Fri, 1 Sep 2017 13:24:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7AC58E0044 for ; Fri, 1 Sep 2017 13:24:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 359952414F for ; Fri, 1 Sep 2017 13:24:00 +0000 (UTC) Date: Fri, 1 Sep 2017 13:24:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@nifi.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (NIFI-4326) ExtractEmailHeaders.java unhandled Exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 01 Sep 2017 13:24:09 -0000 [ 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: 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)