From 4df1b42874bff0e778e89bb9a63c45b527f9a743 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 19 Oct 2022 14:10:41 +0200 Subject: [PATCH] Continued: - added more checks on method/constructor parameter - made more local variables final --- .../jcoreee/bean/ejb/BaseEnterpriseBean.java | 15 +++++++++++++++ .../jcoreee/bean/faces/BaseFacesBean.java | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/org/mxchange/jcoreee/bean/ejb/BaseEnterpriseBean.java b/src/org/mxchange/jcoreee/bean/ejb/BaseEnterpriseBean.java index f57faf0..e0d6755 100644 --- a/src/org/mxchange/jcoreee/bean/ejb/BaseEnterpriseBean.java +++ b/src/org/mxchange/jcoreee/bean/ejb/BaseEnterpriseBean.java @@ -98,6 +98,21 @@ public abstract class BaseEnterpriseBean implements Serializable { // Invoke default constructor this(); + // Validate all parameter + if (null == factoryJndi) { + // Throw IAE + throw new NullPointerException("factoryJndi is null"); //NOI18N + } else if (factoryJndi.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("factoryJndi is empty"); //NOI18N + } else if (null == queueJndi) { + // Throw IAE + throw new NullPointerException("queueJndi is null"); //NOI18N + } else if (queueJndi.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("queueJndi is empty"); //NOI18N + } + // Try it out try { // Get initial context diff --git a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java index f8c066c..be104a1 100644 --- a/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java +++ b/src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java @@ -145,6 +145,15 @@ public abstract class BaseFacesBean implements Serializable { * @return Property value */ protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException { + // Validate parameter + if (null == parameterKey) { + // Throw IAE + throw new NullPointerException("parameterKey is null"); //NOI18N + } else if (parameterKey.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("parameterKey is empty"); //NOI18N + } + // Get context parameter final Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey)); -- 2.39.5