Source:
public boolean doCheckAndSend(boolean withAttachment) throws JobEmailNotificationException, IOException, UnknownJobException, PermissionException { String jobStatus = jobState.getGenericInformation().get(GENERIC_INFORMATION_KEY_NOTIFICATION_EVENT); List<String> jobStatusList = new ArrayList<>(); if (jobStatus != null) { if ("all".equals(jobStatus.toLowerCase())) { jobStatusList = Arrays.asList("JOB_CHANGE_PRIORITY", "JOB_IN_ERROR", "JOB_PAUSED", "JOB_PENDING_TO_FINISHED", "JOB_PENDING_TO_RUNNING", "JOB_RESTARTED_FROM_ERROR", "JOB_RESUMED", "JOB_RUNNING_TO_FINISHED", "JOB_SUBMITTED") .stream() .map(status -> status.toLowerCase()) .collect(Collectors.toList()); } else { jobStatusList = Arrays.asList(jobStatus.toLowerCase().split("\\s*,\\s*")); } } switch (eventType) { case JOB_CHANGE_PRIORITY: case JOB_IN_ERROR: case JOB_PAUSED: case JOB_PENDING_TO_FINISHED: case JOB_PENDING_TO_RUNNING: case JOB_RESTARTED_FROM_ERROR: case JOB_RESUMED: case JOB_RUNNING_TO_FINISHED: case JOB_SUBMITTED: break; default: logger.trace("Event not in the list of email notification, doing nothing"); return false; } if (!PASchedulerProperties.EMAIL_NOTIFICATIONS_ENABLED.getValueAsBoolean()) { logger.debug("Notification emails disabled, doing nothing"); return false; } if (!jobStatusList.contains(eventType.toString().toLowerCase())) { return false; } try { if (withAttachment) { String attachment = getAttachment(); if (attachment != null) { sender.sender(getTo(), getSubject(), getBody(), attachment, getAttachmentName()); FileUtils.deleteQuietly(new File(attachment)); } else { sender.sender(getTo(), getSubject(), getBody()); } } else { sender.sender(getTo(), getSubject(), getBody()); } return true; } catch (EmailException e) { throw new JobEmailNotificationException(String.join(",", getTo()), "Error sending email: " + e.getMessage(), e); } }

Target:
public boolean doCheckAndSend(boolean withAttachment) throws JobEmailNotificationException, IOException, UnknownJobException, PermissionException { String jobStatus = jobState.getGenericInformation().get(GENERIC_INFORMATION_KEY_NOTIFICATION_EVENT); List<String> jobStatusList = new ArrayList<>(); if (jobStatus != null) { if ("all".equals(jobStatus.toLowerCase())) { jobStatusList = Stream.of("JOB_CHANGE_PRIORITY", "JOB_IN_ERROR", "JOB_PAUSED", "JOB_PENDING_TO_FINISHED", "JOB_PENDING_TO_RUNNING", "JOB_RESTARTED_FROM_ERROR", "JOB_RESUMED", "JOB_RUNNING_TO_FINISHED", "JOB_SUBMITTED") .map(status -> status.toLowerCase()) .collect(Collectors.toList()); } else { jobStatusList = Arrays.asList(jobStatus.toLowerCase().split("\\s*,\\s*")); } } switch (eventType) { case JOB_CHANGE_PRIORITY: case JOB_IN_ERROR: case JOB_PAUSED: case JOB_PENDING_TO_FINISHED: case JOB_PENDING_TO_RUNNING: case JOB_RESTARTED_FROM_ERROR: case JOB_RESUMED: case JOB_RUNNING_TO_FINISHED: case JOB_SUBMITTED: break; default: logger.trace("Event not in the list of email notification, doing nothing"); return false; } if (!PASchedulerProperties.EMAIL_NOTIFICATIONS_ENABLED.getValueAsBoolean()) { logger.debug("Notification emails disabled, doing nothing"); return false; } if (!jobStatusList.contains(eventType.toString().toLowerCase())) { return false; } try { if (withAttachment) { String attachment = getAttachment(); if (attachment != null) { sender.sender(getTo(), getSubject(), getBody(), attachment, getAttachmentName()); FileUtils.deleteQuietly(new File(attachment)); } else { sender.sender(getTo(), getSubject(), getBody()); } } else { sender.sender(getTo(), getSubject(), getBody()); } return true; } catch (EmailException e) { throw new JobEmailNotificationException(String.join(",", getTo()), "Error sending email: " + e.getMessage(), e); } }