From d9ab837c4f8bbed48b683ff91856ab66eac26284 Mon Sep 17 00:00:00 2001 From: Florin POP Date: Sat, 13 Apr 2019 03:47:51 +0300 Subject: [PATCH] Avoid infinite loop when cycle in hierarchy In certain cases, cycles in the components hierarchy appear. Due to the current implementation an infinite loop is generated and the thread hogs the CPU. The only option is to kill the JVM. The proposed change avoids this situation. --- .../apache/myfaces/trinidad/component/UIXComponentBase.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java index 6675f25d8..f4ad38124 100644 --- a/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java +++ b/trinidad-api/src/main/java/org/apache/myfaces/trinidad/component/UIXComponentBase.java @@ -401,6 +401,8 @@ public String getClientId(FacesContext context) // Search for an ancestor that is a naming container UIComponent containerComponent = getParent(); + String origId = (null != containerComponent) ? containerComponent.getId() : null; + while (null != containerComponent) { if (containerComponent instanceof NamingContainer) @@ -420,6 +422,8 @@ public String getClientId(FacesContext context) } containerComponent = containerComponent.getParent(); + if (origId != null && origId.equals(containerComponent != null ? containerComponent.getId():null)) + throw new IllegalStateException(); } Renderer renderer = getRenderer(context);