You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by pa...@apache.org on 2012/04/19 11:09:31 UTC
[19/22] git commit: WICKET-4488 URL with a previous page version
ignores requested page based on mount path
WICKET-4488 URL with a previous page version ignores requested page based on mount path
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e6582c52
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e6582c52
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e6582c52
Branch: refs/heads/sandbox/atmosphere
Commit: e6582c5299c53ea6689d8a95c21e47df8c8a8877
Parents: 332108b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Apr 10 16:14:39 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Apr 10 16:16:57 2012 +0300
----------------------------------------------------------------------
.../wicket/core/request/handler/PageProvider.java | 14 +++++---
.../wicket/request/handler/PageProviderTest.java | 25 +++++++++++++++
2 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/e6582c52/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
index f239c4d..50402f6 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
@@ -294,18 +294,22 @@ public class PageProvider implements IPageProvider
private IRequestablePage getStoredPage(final int pageId)
{
IRequestablePage storedPageInstance = getPageSource().getPageInstance(pageId);
- if (storedPageInstance != null &&
- (pageClass == null || pageClass.equals(storedPageInstance.getClass())))
+ if (storedPageInstance != null)
{
- pageInstance = storedPageInstance;
- pageInstanceIsFresh = false;
- if (pageInstance != null)
+ if (pageClass == null || pageClass.equals(storedPageInstance.getClass()))
{
+ pageInstance = storedPageInstance;
+ pageInstanceIsFresh = false;
if (renderCount != null && pageInstance.getRenderCount() != renderCount)
{
throw new StalePageException(pageInstance);
}
}
+ else
+ {
+ // the found page class doesn't match the requested one
+ storedPageInstance = null;
+ }
}
return storedPageInstance;
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/e6582c52/wicket-core/src/test/java/org/apache/wicket/request/handler/PageProviderTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/request/handler/PageProviderTest.java b/wicket-core/src/test/java/org/apache/wicket/request/handler/PageProviderTest.java
index 178339a..fc22a58 100644
--- a/wicket-core/src/test/java/org/apache/wicket/request/handler/PageProviderTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/request/handler/PageProviderTest.java
@@ -21,6 +21,7 @@ import java.text.ParseException;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.MockPage;
+import org.apache.wicket.MockPageWithLink;
import org.apache.wicket.Page;
import org.apache.wicket.RestartResponseAtInterceptPageException;
import org.apache.wicket.WicketTestCase;
@@ -227,6 +228,30 @@ public class PageProviderTest extends WicketTestCase
assertFalse(provider.isPageInstanceFresh());
}
+ /**
+ * https://issues.apache.org/jira/browse/WICKET-4488
+ *
+ * There is a stored page with id = 0 and class Page1.
+ * A following request to page2?0 should not use the stored page with id=0 because
+ * the requested and the found page classes do not match.
+ */
+ @Test
+ public void ignorePageFoundByIdIfItsClassDoesntMatch()
+ {
+ TestMapperContext mapperContext = new TestMapperContext();
+ Page page = new TestPage();
+ mapperContext.getPageManager().touchPage(page);
+ mapperContext.getPageManager().commitRequest();
+
+ // by cleaning session cache we make sure of not being testing the same in-memory instance
+ mapperContext.cleanSessionCache();
+
+ PageProvider provider = new PageProvider(page.getPageId(), MockPageWithLink.class, 0);
+ assertFalse(provider.hasPageInstance());
+ assertEquals(MockPageWithLink.class, provider.getPageInstance().getClass());
+ assertTrue(provider.isPageInstanceFresh());
+ }
+
/** */
public static class TestPage extends WebPage implements IMarkupResourceStreamProvider
{