[ 
https://issues.apache.org/jira/browse/WICKET-6102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15244152#comment-15244152
 ] 

C Quarters commented on WICKET-6102:
------------------------------------

My apologies if this is not the correct place to post this but I think it adds 
context (and maybe another perspective) to this bug.

I have been experiencing this StackOverflowError with <wicket:enclosure> since 
7.0.0 (also in 7.1.0 and 7.2.0). I had no problems with M1 - M6. My call stack 
has the same recursion as in this bug although my line numbers below are 
different because it's 7.2.0 code.

java.lang.StackOverflowError
        at java.lang.StringBuilder.append(StringBuilder.java:136)
        at 
org.apache.wicket.markup.DefaultMarkupCacheKeyProvider.getCacheKey(DefaultMarkupCacheKeyProvider.java:55)
        at org.apache.wicket.markup.MarkupCache.getMarkup(MarkupCache.java:276)
        at 
org.apache.wicket.markup.MarkupFactory.getMarkup(MarkupFactory.java:236)
        at 
org.apache.wicket.markup.MarkupFactory.getMarkup(MarkupFactory.java:194)
        at 
org.apache.wicket.MarkupContainer.getAssociatedMarkup(MarkupContainer.java:456)
        at 
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:95)
        at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:502)
        at org.apache.wicket.Component.getMarkup(Component.java:755)
        at 
org.apache.wicket.markup.html.internal.Enclosure.getChild(Enclosure.java:138)
        at 
org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:173)
        at 
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:90)
        at 
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
        at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:502)
        at org.apache.wicket.Component.getMarkup(Component.java:755)
        at 
org.apache.wicket.markup.html.internal.Enclosure.getChild(Enclosure.java:138)
        at 
org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:173)
        at 
org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:90)
        at 
org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
        at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:502)
        at org.apache.wicket.Component.getMarkup(Component.java:755)
etc

I've tried creating a simple example illustrating the problem but have not been 
able to. It only happens in two large applications I work on.

I've worked around the problem since 7.0.0 by patching
org.apache.wicket.markup.html.internal.Enclosure

In the call stack loop you see Enclosure.isVisible(). In my own code I follow 
this practice
http://wicketinaction.com/2011/11/implement-wicket-component-visibility-changes-properly/
so I deleted Enclosure.isVisible() (!!!) because setVisible() is called in 
Enclosure.onConfigure(). However, this led to NPEs so I added null checking in 
Enclosure.onConfigure() and Enclosure.getChild(). For me these changes work 
well but I'm probably being naive. Is there a reason why it's important to have 
code in Enclosure.isVisible() ? Is there any merit in my changes that might be 
incorporated into Wicket?

Here's a diff showing how I modify Enclosure.java 

diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
index e68f4e0..7616e55 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
@@ -135,7 +135,9 @@
                if (childComponent == null)
                {
                        // try to find child when resolved
-                       childComponent = getChildComponent(new 
MarkupStream(getMarkup()), getEnclosureParent());
+                 IMarkupFragment markup = getMarkup();
+                 if( markup != null )
+                   childComponent = getChildComponent(new 
MarkupStream(markup), getEnclosureParent());
                }
                return childComponent;
        }
@@ -166,23 +168,22 @@
                
                return childController;
        }
-
-       @Override
-       public boolean isVisible()
-       {
-               return getChild().determineVisibility();
-       }
        
        @Override
        protected void onConfigure()
        {
-               super.onConfigure();
-               final Component child = getChild();
-               
-               child.configure();
-               boolean childVisible = child.determineVisibility();
-               
-               setVisible(childVisible);
+         super.onConfigure();
+         boolean childVisible = false;
+
+         final Component child = getChild();
+
+         if( child != null )
+         {
+           child.configure();
+           childVisible = child.determineVisibility();
+         }
+    
+    setVisible(childVisible);
        }
 
        @Override



> StackoverflowError related to enclosures
> ----------------------------------------
>
>                 Key: WICKET-6102
>                 URL: https://issues.apache.org/jira/browse/WICKET-6102
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.2.0, 8.0.0-M1
>            Reporter: Martin Grigorov
>             Fix For: 7.3.0, 8.0.0-M1
>
>
> I see the following exception when try to start Wicket-Bootstrap's samples 
> with 7.3.0-SNAPSHOT.
> There is no such problem with 7.2.0
> {code}
> java.lang.StackOverflowError
>       at java.util.ArrayList.iterator(ArrayList.java:834)
>       at 
> org.apache.wicket.MarkupContainer$1MarkupChildIterator.refreshInternalIteratorIfNeeded(MarkupContainer.java:608)
>       at 
> org.apache.wicket.MarkupContainer$1MarkupChildIterator.hasNext(MarkupContainer.java:574)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:134)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162)
>       at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123)
>       at 
> org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:968)
>       at 
> org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:77)
>       at 
> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
>       at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:504)
>       at org.apache.wicket.Component.getMarkup(Component.java:755)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.getChild(Enclosure.java:136)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:171)
>       at 
> org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:90)
>       at 
> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
>       at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:504)
>       at org.apache.wicket.Component.getMarkup(Component.java:755)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.getChild(Enclosure.java:136)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:171)
>       at 
> org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:90)
>       at 
> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
>       at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:504)
>       at org.apache.wicket.Component.getMarkup(Component.java:755)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.getChild(Enclosure.java:136)
>       at 
> org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:171)
>       at 
> org.apache.wicket.markup.html.panel.AbstractMarkupSourcingStrategy.searchMarkupInTransparentResolvers(AbstractMarkupSourcingStrategy.java:90)
>       at 
> org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.getMarkup(AssociatedMarkupSourcingStrategy.java:123)
>       at org.apache.wicket.MarkupContainer.getMarkup(MarkupContainer.java:504)
>       at org.apache.wicket.Component.getMarkup(Component.java:755)
> ...
> {code}
> To reproduce:
> * git clone https://github.com/l0rdn1kk0n/wicket-bootstrap/
> * edit pom.xml and set Wicket version to 7.3.0-SNAPSHOT
> * git checkout db35564a0c0972da13448545078184ae0e9a009b
> * mvn clean install
> * cd bootstrap-samples
> * mvn jetty:run



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to