marco fago created MYFACES-3589:
-----------------------------------
Summary: CLONE - StackOverflowError if a composite component implementation uses another composite component
Key: MYFACES-3589
URL: https://issues.apache.org/jira/browse/MYFACES-3589
Project: MyFaces Core
Issue Type: Bug
Components: JSR-314
Affects Versions: 2.0.0-beta-3
Reporter: marco fago
Assignee: Jakob Korherr
Fix For: 2.0.0-beta-3
Attachments: MYFACES-2561-2.patch, MYFACES-2561.patch, test.xhtml, test1.xhtml, test2.xhtml
If you use another composite component in your composite component's implementation you will get a StackOverflowError.
javax.faces.FacesException: java.lang.StackOverflowError
at org.apache.myfaces.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
at org.apache.myfaces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:216)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.lang.StackOverflowError
at java.util.ArrayList.toArray(ArrayList.java:306)
at java.util.logging.Logger.getHandlers(Logger.java:1200)
at java.util.logging.LogManager$RootLogger.getHandlers(LogManager.java:1019)
at java.util.logging.Logger.log(Logger.java:454)
at java.util.logging.Logger.doLog(Logger.java:480)
at java.util.logging.Logger.logp(Logger.java:680)
at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:167)
at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:135)
at org.apache.catalina.connector.Request.setAttribute(Request.java:1448)
at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)
at org.apache.myfaces.context.servlet.RequestMap.setAttribute(RequestMap.java:53)
at org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:113)
at org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:1)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.setScope(FacesCompositeELResolver.java:191)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:139)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
at org.apache.el.parser.AstValue.getValue(AstValue.java:107)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:84)
at org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.get(CompositeComponentELResolver.java:245)
at javax.el.MapELResolver.getValue(MapELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:140)
at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:84)
at org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.get(CompositeComponentELResolver.java:245)
at javax.el.MapELResolver.getValue(MapELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:140)
at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:84)
at org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.get(CompositeComponentELResolver.java:245)
at javax.el.MapELResolver.getValue(MapELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:140)
at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.myfaces.view.facelets.el.TagValueExpression.getValue(TagValueExpression.java:84)
at org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.get(CompositeComponentELResolver.java:245)
at javax.el.MapELResolver.getValue(MapELResolver.java:51)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:140)
at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
......
......
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[ https://issues.apache.org/jira/browse/MYFACES-3589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13425649#comment-13425649 ]
marco fago commented on MYFACES-3589:
-------------------------------------
Probably my description or understanding was wrong.
Here comes a test case to reproduce the bug I've found:
test1
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="value" type="java.lang.String" default="test"/>
</cc:interface>
<cc:implementation>
<test:test2 value="#{cc.attrs.value}"/>
</cc:implementation>
test2
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:test="http://java.sun.com/jsf/composite/test"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:cc="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<cc:interface>
<cc:attribute name="value" type="java.lang.String" required="true" />
</cc:interface>
<!-- IMPLEMENTATION -->
<cc:implementation>
<test:test3 value="#{fn:contains(cc.attrs.value,'t') ? cc.attrs.value : 'nope'}"/>
</cc:implementation>
</html>
test3
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite">
<cc:interface>
<cc:attribute name="value" type="java.lang.String" required="true" />
</cc:interface>
<cc:implementation>
#{cc.attrs.value}
</cc:implementation>
</html>
Adding <test:test1/> to your page you will get a java.lang.StackOverflowError.
The problem seems to be related to the 'fn:contains....' part in test2 implementation (but not specifically to that function since I tried with a custom fn and got the same error).
Replacing that with
<test:test3 value="#{cc.attrs.value}"/>
all works fine.
> Regex for cc.attrs doesn't take into account start with left parenthesis
> ------------------------------------------------------------------------
>
> Key: MYFACES-3589
> URL: https://issues.apache.org/jira/browse/MYFACES-3589
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.1.8
> Reporter: marco fago
> Assignee: Jakob Korherr
> Attachments: MYFACES-2561-2.patch, MYFACES-2561.patch, test.xhtml, test1.xhtml, test2.xhtml
>
>
> See MYFACES-2651.
> In particular, there is still a case in which the proposed solution won't work.
> Consider the component test 1 slightly modified:
> <cc:interface name="test1">
> <cc:attribute name="test" required="true" />
> </cc:interface>
> <cc:implementation>
> test1
> <t2:test2 test="#{myLibrary:myFunction(...) or cc.attrs.test}" />
> </cc:implementation>
> In that case the regex expression looking for cc.attrs will exclude the expression because cc.attrs is preceded by a left parenthesis (as stated in CompositeComponentELUtils).
> Changing to
> <t2:test2 test="#{cc.attrs.test or myLibrary:myFunction(...)}" />
> will work.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[ https://issues.apache.org/jira/browse/MYFACES-3589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13425284#comment-13425284 ]
Leonardo Uribe commented on MYFACES-3589:
-----------------------------------------
I checked and I don't see any problem. There are two regex used to handle cc:
/**
* A regular expression used to determine if cc is used in an expression String.
*/
public static final Pattern CC_EXPRESSION_REGEX = Pattern.compile(".*[^\\w\\.]cc[^\\w].*");
/**
* A regular expression used to determine if cc.attrs is used as a method expression
* in an expression String. This means cc.attrs must occur, must stand before a '(',
* because otherwise it would be a method parameter (EL 2.2), and there must be no '.' after
* cc.attrs unless there is a left parenthesis before it (e.g. #{cc.attrs.method(bean.parameter)}).
*
* Explanation of the parts:
* - [^\\(]* - There can be any character except a '(' before cc.attrs
* - [^\\w\\.\\(] - There must be no word character, dot, or left parenthesis directly before cc.attrs
* - cc\\.attrs\\. - "cc.attrs." must occur
* - [^\\.]* - There must be no dot after cc.attrs to indicate a method invocation on cc.attrs
* - (\\(.*)? - If there is a left paranthesis after cc.attrs, a dot is allowed again
*/
public static final Pattern CC_ATTRS_METHOD_EXPRESSION_REGEX
= Pattern.compile("[^\\(]*[^\\w\\.\\(]cc\\.attrs\\.[^\\.]*(\\(.*)?");
Both are correct. In the case presented, cc.attrs.test does not point to a MethodExpression, so there is no need to do the indirection hack. Please note MYFACES-3383 was solved recently, and the solution proposed is not in 2.1.8, so maybe this is related in some way.
There is no evidence about any problem here. If no objections, I'll close this issue as invalid.
> Regex for cc.attrs doesn't take into account start with left parenthesis
> ------------------------------------------------------------------------
>
> Key: MYFACES-3589
> URL: https://issues.apache.org/jira/browse/MYFACES-3589
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.1.8
> Reporter: marco fago
> Assignee: Jakob Korherr
> Attachments: MYFACES-2561-2.patch, MYFACES-2561.patch, test.xhtml, test1.xhtml, test2.xhtml
>
>
> See MYFACES-2651.
> In particular, there is still a case in which the proposed solution won't work.
> Consider the component test 1 slightly modified:
> <cc:interface name="test1">
> <cc:attribute name="test" required="true" />
> </cc:interface>
> <cc:implementation>
> test1
> <t2:test2 test="#{myLibrary:myFunction(...) or cc.attrs.test}" />
> </cc:implementation>
> In that case the regex expression looking for cc.attrs will exclude the expression because cc.attrs is preceded by a left parenthesis (as stated in CompositeComponentELUtils).
> Changing to
> <t2:test2 test="#{cc.attrs.test or myLibrary:myFunction(...)}" />
> will work.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[ https://issues.apache.org/jira/browse/MYFACES-3589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Leonardo Uribe resolved MYFACES-3589.
-------------------------------------
Resolution: Fixed
Fix Version/s: 2.1.9
2.0.15
Thanks for the test. It makes easier to find and solve the problem.
I changed the name of the issue to a more descriptive one (it is not related to the regex):
Allow multiple resolutions of cc into de same EL expression.
There is a bug in CompositeComponentELUtils. When removeCompositeComponentForResolver() is called, it is not taken into account that nested calls resolving "cc" could be done. The fix was already included in MYFACES-3383, but there was an old line:
facesContext.getAttributes().remove(CURRENT_COMPOSITE_COMPONENT_KEY);
that just need to be removed, because a list/stack is used instead a single attribute.
Thanks for your attention in the details.
> Allow multiple resolutions of cc into the same EL expression
> ------------------------------------------------------------
>
> Key: MYFACES-3589
> URL: https://issues.apache.org/jira/browse/MYFACES-3589
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 2.1.8
> Reporter: marco fago
> Assignee: Jakob Korherr
> Fix For: 2.0.15, 2.1.9
>
> Attachments: MYFACES-2561-2.patch, MYFACES-2561.patch, test.xhtml, test1.xhtml, test2.xhtml
>
>
> See MYFACES-2651.
> In particular, there is still a case in which the proposed solution won't work.
> Consider the component test 1 slightly modified:
> <cc:interface name="test1">
> <cc:attribute name="test" required="true" />
> </cc:interface>
> <cc:implementation>
> test1
> <t2:test2 test="#{myLibrary:myFunction(...) or cc.attrs.test}" />
> </cc:implementation>
> In that case the regex expression looking for cc.attrs will exclude the expression because cc.attrs is preceded by a left parenthesis (as stated in CompositeComponentELUtils).
> Changing to
> <t2:test2 test="#{cc.attrs.test or myLibrary:myFunction(...)}" />
> will work.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira