diff --git a/nifi-provenance-reporting-tasks/src/main/java/io/egm/nifi/reporting/EmailProvenanceReporter.java b/nifi-provenance-reporting-tasks/src/main/java/io/egm/nifi/reporting/EmailProvenanceReporter.java index e00384a..b7f8d48 100644 --- a/nifi-provenance-reporting-tasks/src/main/java/io/egm/nifi/reporting/EmailProvenanceReporter.java +++ b/nifi-provenance-reporting-tasks/src/main/java/io/egm/nifi/reporting/EmailProvenanceReporter.java @@ -231,7 +231,7 @@ public PasswordAuthentication getPasswordAuthentication() { */ private InternetAddress[] toInetAddresses(final ReportingContext context, PropertyDescriptor propertyDescriptor) throws AddressException { - InternetAddress[] parse = new InternetAddress[0]; + InternetAddress[] parse; final String value = context.getProperty(propertyDescriptor).getValue(); if (value == null || value.isEmpty()) { @@ -278,7 +278,8 @@ private Charset getCharset(final ReportingContext context) { private String getSpecificRecipientValue(final ReportingContext context, final Map event) { final String specificRecipientAttributeName = context.getProperty(SPECIFIC_RECIPIENT_ATTRIBUTE_NAME).getValue(); - return (String) event.get(specificRecipientAttributeName); + Map eventPreviousAttributes = (Map) event.get("previous_attributes"); + return eventPreviousAttributes.get(specificRecipientAttributeName); } private String composeMessageContent(final Map event) { @@ -349,7 +350,10 @@ public void sendErrorEmail(Map event, ReportingContext context) final Session mailSession = this.createMailSession(properties, context); final Message message = new MimeMessage(mailSession); InternetAddress[] inetAddressesArray; - String specificRecipientAttributeValue = getSpecificRecipientValue(context, event); + String specificRecipientAttributeValue = null; + if (event.containsKey("previous_attributes") && context.getProperty(SPECIFIC_RECIPIENT_ATTRIBUTE_NAME).getValue() != null) { + specificRecipientAttributeValue = getSpecificRecipientValue(context, event); + } if (specificRecipientAttributeValue != null) { inetAddressesArray = (InternetAddress[]) Stream.of(