You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by me...@apache.org on 2022/11/07 16:24:08 UTC
[myfaces] branch 2.3.x updated: MYFACES-4492: don't NPE when no label is set (#375)
This is an automated email from the ASF dual-hosted git repository.
melloware pushed a commit to branch 2.3.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/2.3.x by this push:
new 16d93768a MYFACES-4492: don't NPE when no label is set (#375)
16d93768a is described below
commit 16d93768acd2e3edad009a67a91814837a44bd18
Author: Paul A. Nicolucci <pn...@gmail.com>
AuthorDate: Mon Nov 7 11:24:02 2022 -0500
MYFACES-4492: don't NPE when no label is set (#375)
---
api/src/main/java/javax/faces/model/SelectItem.java | 4 ----
.../myfaces/shared/renderkit/html/util/SelectItemsUtils.java | 9 ++++++++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/api/src/main/java/javax/faces/model/SelectItem.java b/api/src/main/java/javax/faces/model/SelectItem.java
index 3829f3f90..ed3483c52 100755
--- a/api/src/main/java/javax/faces/model/SelectItem.java
+++ b/api/src/main/java/javax/faces/model/SelectItem.java
@@ -141,10 +141,6 @@ public class SelectItem implements Serializable
public void setLabel(String label)
{
- if (label == null)
- {
- throw new NullPointerException("label");
- }
_label = label;
}
diff --git a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SelectItemsUtils.java b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SelectItemsUtils.java
index 98683608b..69ddfc148 100644
--- a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SelectItemsUtils.java
+++ b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/SelectItemsUtils.java
@@ -204,7 +204,14 @@ public class SelectItemsUtils
//check if isEscape() = true first.
if (escape || selectItem.isEscape())
{
- writer.writeText(selectItem.getLabel(), null);
+ String label = selectItem.getLabel();
+
+ if(label == null)
+ {
+ label = "";
+ }
+
+ writer.writeText(label, null);
}
else
{