From: Roland Häder Date: Wed, 19 Oct 2022 12:54:17 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=54cd0f7dfd133bc61ab98d157a7b10c1beb0fead;p=jfinancials-mailer-ejb.git Continued: - made more local variables final - added isEmpty() check on key (should never be empty) --- diff --git a/src/java/org/mxchange/jfinancials/model/mailer/FinancialsMailerSingletonBean.java b/src/java/org/mxchange/jfinancials/model/mailer/FinancialsMailerSingletonBean.java index 03b1877..451141f 100644 --- a/src/java/org/mxchange/jfinancials/model/mailer/FinancialsMailerSingletonBean.java +++ b/src/java/org/mxchange/jfinancials/model/mailer/FinancialsMailerSingletonBean.java @@ -146,15 +146,18 @@ public class FinancialsMailerSingletonBean extends BaseMailerBean implements Del // Are some variables set? if ((emailWrapper.getTemplateVariables() != null) && (!emailWrapper.getTemplateVariables().isEmpty())) { // Add all variables - for (Map.Entry entry : emailWrapper.getTemplateVariables().entrySet()) { + for (final Map.Entry entry : emailWrapper.getTemplateVariables().entrySet()) { // Get key/value - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); + final String key = (String) entry.getKey(); + final String value = (String) entry.getValue(); // Both should not be empty if (null == key) { // Throw NPE throw new NullPointerException("key is null"); //NOI18N + } else if (key.isEmpty()) { + // Throw IAE + throw new NullPointerException("key is empty"); //NOI18N } else if (null == value) { // Throw NPE again throw new NullPointerException(MessageFormat.format("value for key={0} is null", key)); //NOI18N