From 54cd0f7dfd133bc61ab98d157a7b10c1beb0fead Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Oct 2022 14:54:17 +0200 Subject: [PATCH] Continued: - made more local variables final - added isEmpty() check on key (should never be empty) --- .../model/mailer/FinancialsMailerSingletonBean.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 -- 2.39.5