You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Maarten Billemont (JIRA)" <ji...@apache.org> on 2009/01/09 12:08:59 UTC
[jira] Commented: (WICKET-2013) Session doesn't get invalidated
when using RestartResponseException.
[ https://issues.apache.org/jira/browse/WICKET-2013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12662322#action_12662322 ]
Maarten Billemont commented on WICKET-2013:
-------------------------------------------
Okay, my formatting wasn't applied, that kind of sucked.
In any case; the above code causes the following exception; because the MyPage constructor can't get rid of the active session which has a name set in it:
java.lang.IllegalStateException: Request processing executed 100 steps, which means it is probably in an infinite loop.
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1361)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:498)
at org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:484)
at org.apache.wicket.protocol.http.MockWebApplication.processRequestCycle(MockWebApplication.java:472)
at test.spike.net.link.safeonline.TinyTests.wicketTest(TinyTests.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Session doesn't get invalidated when using RestartResponseException.
> --------------------------------------------------------------------
>
> Key: WICKET-2013
> URL: https://issues.apache.org/jira/browse/WICKET-2013
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4-RC1
> Reporter: Maarten Billemont
>
> When invalidating a session using Session.get().invalidateNow(), I normally want to stop processing the current request. When I do this in a constructor of a page which might be extended by another page, I don't want any other code to get exected. Not my own, not that of any possible pages extending my page.
> To do this, I throw an AbortException or a RestartResponseException. However, it seems the session isn't actually properly cleaned this way.
> The following code demonstrates the problem:
> {code:title=TinyTests.java}
> package test.spike;
> import org.apache.wicket.Page;
> import org.apache.wicket.Request;
> import org.apache.wicket.Response;
> import org.apache.wicket.RestartResponseException;
> import org.apache.wicket.Session;
> import org.apache.wicket.markup.html.WebPage;
> import org.apache.wicket.protocol.http.WebApplication;
> import org.apache.wicket.protocol.http.WebSession;
> import org.apache.wicket.util.tester.WicketTester;
> import org.junit.Test;
> public class TinyTests {
> public static class MyApp extends WebApplication {
> /**
> * {@inheritDoc}
> */
> @Override
> public Class<? extends Page> getHomePage() {
> return MyPage.class;
> }
> /**
> * {@inheritDoc}
> */
> @Override
> public Session newSession(Request request, Response response) {
> return new MySession(request);
> }
> }
> public static class MySession extends WebSession {
> public MySession(Request request) {
> super(request);
> }
> public static MySession get() {
> return (MySession) Session.get();
> }
> private static final long serialVersionUID = 1L;
> private String name;
> public void setName(String name) {
> this.name = name;
> }
> public String getName() {
> return name;
> }
> }
> public static class MyPage extends WebPage {
> public MyPage() {
> if (MySession.get().getName() != null) {
> Session.get().invalidateNow();
> throw new RestartResponseException(getClass());
> }
> }
> }
> @Test
> public void wicketTest() {
> WicketTester wicket = new WicketTester(new MyApp());
> wicket.processRequestCycle();
> MySession.get().setName("foo");
> wicket.processRequestCycle();
> }
> }
> {code}
> {code:title=TinyTests$MyPage.html}
> <html>
> </html>
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.