You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by da...@apache.org on 2015/05/01 18:19:16 UTC

wicket git commit: Reproduced WICKET-5898

Repository: wicket
Updated Branches:
  refs/heads/master c9e5ccd10 -> b0be030b1


Reproduced WICKET-5898

This testcase reproduces WICKET-5898. It contains 3 test methods
of which 2 are @ignored. You should remove the @ignore to trigger
the StackOverflowError when testing.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b0be030b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b0be030b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b0be030b

Branch: refs/heads/master
Commit: b0be030b1ddbe7bee19d2e9650c2e45b486060c1
Parents: c9e5ccd
Author: Martijn Dashorst <ma...@gmail.com>
Authored: Fri May 1 18:18:55 2015 +0200
Committer: Martijn Dashorst <ma...@gmail.com>
Committed: Fri May 1 18:18:55 2015 +0200

----------------------------------------------------------------------
 .../transparentresolvers/TestWicket5898.java    | 104 +++++++++++++++++++
 .../transparentresolvers/Wicket5898Page.html    |  10 ++
 .../transparentresolvers/Wicket5898Page.java    |  66 ++++++++++++
 .../transparentresolvers/Wicket5898Page2.html   |  10 ++
 .../transparentresolvers/Wicket5898Page2.java   |  64 ++++++++++++
 5 files changed, 254 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/b0be030b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TestWicket5898.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TestWicket5898.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TestWicket5898.java
new file mode 100644
index 0000000..f154948
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/TestWicket5898.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.queueing.transparentresolvers;
+
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This page causes a {@code StackOverflowError} when trying to update the component {@code label}
+ * from an Ajax request. The page renders normally in normal page requests or fallback requests.
+ *
+ * Things of note: the test passes when you add the {@code TransparentWebMarkupContainer} as the
+ * first component to the page, instead of it being the last component to be added.
+ *
+ * It appears that the {@code src} attribute of the {@code <img>} tag inside the {@code group}
+ * {@code WebMarkupContainer} is significant in triggering this bug. Removing the {@code group} or
+ * the {@code src} attribute lets the test pass.
+ */
+public class TestWicket5898
+{
+	private WicketTester tester;
+
+	/**
+	 * Sets up the tester.
+	 */
+	@Before
+	public void setUp()
+	{
+		tester = new WicketTester();
+	}
+
+	/**
+	 * This test should pass, it is just here to validate that the page renders initially, and using
+	 * a normal, non-AJAX request cycle.
+	 */
+	@Test
+	public void normalRequestDoesntCauseStackOverflow()
+	{
+		tester.startPage(Wicket5898Page.class);
+
+		// the page renders normally using normal web requests
+		tester.assertRenderedPage(Wicket5898Page.class);
+
+		// the page renders normally when clicking on a link without using AJAX
+		tester.clickLink("link", false);
+		tester.assertRenderedPage(Wicket5898Page.class);
+	}
+
+	/**
+	 * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested
+	 * TransparentWebMarkupContainers is updated. This particular test case is caused by Wicket's
+	 * insertion of a TransparentWebMarkupContainer automatically due to a {@code src} attribute
+	 * that might need rewriting.
+	 */
+	@Test
+	@Ignore("This test fails, should be enabled to trigger WICKET-5898")
+	public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow()
+	{
+		tester.startPage(Wicket5898Page.class);
+
+		// the page renders normally using normal web requests
+		tester.assertRenderedPage(Wicket5898Page.class);
+
+		// without WICKET-5898 fixed the statement below causes a StackOverflowError
+		tester.clickLink("link", true);
+		tester.assertComponentOnAjaxResponse("label");
+	}
+
+	/**
+	 * Tests the WICKET-5898 issue of triggering a StackOverflowError when a component inside nested
+	 * TransparentWebMarkupContainers is updated. This particular test case is caused by having two
+	 * TransparentWebMarkupContainers nested and trying to update a label that was added to the
+	 * outer TWMC.
+	 */
+	@Test
+	@Ignore("This test fails, should be enabled to trigger WICKET-5898")
+	public void ajaxRequestForComponentInTransparentWebMarkupContainerShouldntCauseStackOverflow2()
+	{
+		tester.startPage(Wicket5898Page2.class);
+
+		// the page renders normally using normal web requests
+		tester.assertRenderedPage(Wicket5898Page2.class);
+
+		// without WICKET-5898 fixed the statement below causes a StackOverflowError
+		tester.clickLink("link", true);
+		tester.assertComponentOnAjaxResponse("label");
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/b0be030b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html
new file mode 100644
index 0000000..f3a861c
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+	<div wicket:id="twmc">
+		<span wicket:id="label"></span>
+		<span wicket:id="group"><img src="foo.gif"></span>
+	</div>
+	<a href="#" wicket:id="link"></a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/b0be030b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java
new file mode 100644
index 0000000..58dd9f9
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.queueing.transparentresolvers;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * A test page for triggering a StackOverflowError when updating a component inside a
+ * {@link TransparentWebMarkupContainer} using AJAX.
+ */
+public class Wicket5898Page extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Constructor
+	 */
+	public Wicket5898Page()
+	{
+		final Label label = new Label("label", "Label");
+		label.setOutputMarkupId(true);
+		add(label);
+
+		// The src attribute of the image tag inside this WebMarkupContainer is
+		// essential in triggering this bug. This causes Wicket to insert an
+		// autocomponent (also a TransparentWebMarkupContainer)
+		add(new WebMarkupContainer("group"));
+
+		// if you add this TransparentWebMarkupContainer as first component in
+		// the page (i.e. move line 50 to line 39), the test passes
+		add(new TransparentWebMarkupContainer("twmc"));
+
+		// a non-AJAX click on this link passes the test case, an AJAX request
+		// fails with a StackOverflowError
+		add(new AjaxFallbackLink<Void>("link")
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void onClick(AjaxRequestTarget target)
+			{
+				if (target != null)
+					target.add(label);
+			}
+		});
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/b0be030b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html
new file mode 100644
index 0000000..9c60648
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<body>
+	<div wicket:id="twmc">
+		<span wicket:id="label"></span>
+		<span wicket:id="group"></span>
+	</div>
+	<a href="#" wicket:id="link"></a>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/b0be030b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java
new file mode 100644
index 0000000..1a85c72
--- /dev/null
+++ b/wicket-core/src/test/java/org/apache/wicket/queueing/transparentresolvers/Wicket5898Page2.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.queueing.transparentresolvers;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
+import org.apache.wicket.markup.html.TransparentWebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+
+/**
+ * A test page for triggering a StackOverflowError when updating a component inside a
+ * {@link TransparentWebMarkupContainer} using AJAX.
+ */
+public class Wicket5898Page2 extends WebPage
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * Constructor.
+	 */
+	public Wicket5898Page2()
+	{
+		final Label label = new Label("label", "Label");
+		label.setOutputMarkupId(true);
+		add(label);
+
+		// Adding a TransparentWebMarkupContainer to the outer TransparentWebMarkupContainer causes
+		// a StackOverflowException
+		add(new TransparentWebMarkupContainer("group"));
+
+		// if you add this TransparentWebMarkupContainer as first component in
+		// the page (i.e. move line 48 to line 38), the test passes
+		add(new TransparentWebMarkupContainer("twmc"));
+
+		// a non-AJAX click on this link passes the test case, an AJAX request
+		// fails with a StackOverflowError
+		add(new AjaxFallbackLink<Void>("link")
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void onClick(AjaxRequestTarget target)
+			{
+				if (target != null)
+					target.add(label);
+			}
+		});
+	}
+}