Details
Description
If second parameter - the componentResource:
UIViewRoot.addComponentResource(FacesContext context, UIComponent componentResource)
has null id then StackOverflowError occurs:
Caused by: java.lang.StackOverflowError
at java.lang.ThreadLocal.get(ThreadLocal.java:124)
at javax.faces.context.FacesContext.getCurrentInstance(FacesContext.java:71)
at javax.faces.component.UIComponentBase.getFacesContext(UIComponentBase.java:1057)
at javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:174)
at javax.faces.component._ComponentChildrenList.childRemoved(_ComponentChildrenList.java:123)
at javax.faces.component._ComponentChildrenList.remove(_ComponentChildrenList.java:147)
at javax.faces.component._ComponentChildrenList.removeChildrenFromParent(_ComponentChildrenList.java:136)
at javax.faces.component._ComponentChildrenList.add(_ComponentChildrenList.java:76)
at javax.faces.component._ComponentChildrenList.add(_ComponentChildrenList.java:30)
at javax.faces.component.UIViewRoot.addComponentResource(UIViewRoot.java:188)
at org.apache.myfaces.renderkit.html.HtmlStylesheetRenderer.processEvent(HtmlStylesheetRenderer.java:86)
at javax.faces.component.UIComponent$EventListenerWrapper.processEvent(UIComponent.java:1098)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:43)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:1955)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:504)
at javax.faces.component.UIComponentBase._publishPostAddToViewEvent(UIComponentBase.java:201)
at javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:186)
at javax.faces.component._ComponentChildrenList.updateParent(_ComponentChildrenList.java:128)
at javax.faces.component._ComponentChildrenList.add(_ComponentChildrenList.java:79)
at javax.faces.component._ComponentChildrenList.add(_ComponentChildrenList.java:30)
at javax.faces.component.UIViewRoot.addComponentResource(UIViewRoot.java:188)
at org.apache.myfaces.renderkit.html.HtmlStylesheetRenderer.processEvent(HtmlStylesheetRenderer.java:86)
at javax.faces.component.UIComponent$EventListenerWrapper.processEvent(UIComponent.java:1098)
....
This probably does not happen if componentResource is created from a facelet but only if it created from java code (a listener in my case)