You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2021/08/16 11:21:35 UTC

[myfaces] branch master updated: MYFACES-4409 possible NPE in CheckDuplicateIdFaceletUtils

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

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new af95efc  MYFACES-4409 possible NPE in CheckDuplicateIdFaceletUtils
af95efc is described below

commit af95efc19fe18cd538bca083a6ba76def5033886
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Mon Aug 16 13:21:28 2021 +0200

    MYFACES-4409 possible NPE in CheckDuplicateIdFaceletUtils
---
 .../compiler/CheckDuplicateIdFaceletUtils.java     | 24 ++++++++++++----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
index 0c9e7ab..1c59d29 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
@@ -112,25 +112,27 @@ public final class CheckDuplicateIdFaceletUtils
 
     private static DuplicateIdException createAndQueueException(FacesContext context, UIComponent component, String id)
     {
-        String message = "Component with duplicate id \"" + id + "\" found. The first component is ";
+        String message = "Component with duplicate id \"" + id + "\" found.";
 
-        
         // We report as problematic the second component. The client (an exception handler mostly)
         // has the possibility to report all about the second component, 
         // but the first component is hard to find, especially in large view with tons of naming containers
         // So we do here two things:
         // 1) provide an info about the first component in exception message 
         UIComponent firstComponent = context.getViewRoot().findComponent(id);
-        Location location = (Location) firstComponent.getAttributes().get(UIComponent.VIEW_LOCATION_KEY);
-        if (location != null)
-        {
-            message += location.toString();
-        }
-        else
+        if (firstComponent != null)
         {
-            // location is not available in production mode or if the component
-            // doesn't come from Facelets VDL.
-            message += ComponentUtils.getPathToComponent(firstComponent);
+            Location location = (Location) firstComponent.getAttributes().get(UIComponent.VIEW_LOCATION_KEY);
+            if (location != null)
+            {
+                message += " The first component is " + location.toString();
+            }
+            else
+            {
+                // location is not available in production mode or if the component
+                // doesn't come from Facelets VDL.
+                message += " The first component is " + ComponentUtils.getPathToComponent(firstComponent);
+            }
         }
 
         // 2) we store the first commponent in exception attributes