You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pa...@apache.org on 2022/11/07 12:05:20 UTC

[myfaces] branch 2.3-next updated: MYFACES-4492: don't NPE when no label is set

This is an automated email from the ASF dual-hosted git repository.

paulnicolucci pushed a commit to branch 2.3-next
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.3-next by this push:
     new 73052857c MYFACES-4492: don't NPE when no label is set
     new c5f6f9635 Merge pull request #373 from pnicolucci/MYFACES-4492-23Next
73052857c is described below

commit 73052857cc610c6a030de0a3347efa4da0883694
Author: Paul Nicolucci <pn...@gmail.com>
AuthorDate: Sun Nov 6 19:16:17 2022 -0500

    MYFACES-4492: don't NPE when no label is set
---
 api/src/main/java/javax/faces/model/SelectItem.java              | 4 ----
 .../org/apache/myfaces/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/impl/src/main/java/org/apache/myfaces/renderkit/html/util/SelectItemsUtils.java b/impl/src/main/java/org/apache/myfaces/renderkit/html/util/SelectItemsUtils.java
index f5bea4613..5bf2c76a5 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/util/SelectItemsUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/util/SelectItemsUtils.java
@@ -177,7 +177,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
                 {