]> git.mxchange.org Git - jfinancials-mailer-ejb.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 12:54:17 +0000 (14:54 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 12:54:17 +0000 (14:54 +0200)
- made more local variables final
- added isEmpty() check on key (should never be empty)

src/java/org/mxchange/jfinancials/model/mailer/FinancialsMailerSingletonBean.java

index 03b1877b6f05182cde5fe6a88131169fb1b77288..451141f5172c841c05f6e7ea67a54368ce71f2a8 100644 (file)
@@ -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<Object, Object> entry : emailWrapper.getTemplateVariables().entrySet()) {
+                       for (final Map.Entry<Object, Object> 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