You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2011/02/24 09:34:38 UTC

[jira] Commented: (WICKET-3477) Exception when setting session default timezone with GatherExtendedBrowserInfo

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

Martin Grigorov commented on WICKET-3477:
-----------------------------------------

This indeed will not work.
There are two problems:
- there is no request handler yet at that time (thus the NPE)
- I fixed this locally by using app.getHomePage's url as start point in this case and then the problem is that you call "getClientInfo()" from the Session constructor. Combined with "setGatherExtendedBrowserInfo(true)" this tries to use BrowserInfoPage to get the client info from the browser by doing temporary redirect to BrowserInfoPage and then this page needs the current session at one point and since the call has started from the session constructor this session is not yet completely constructed and the session is not set in the current ThreadContext (ThreadLocal) and a new call to Application.newSession() is made and all starts from the beginning.

The working and simple (IMO) solution is:
- remove getRequestCycleSettings().setGatherExtendedBrowserInfo(true); from MyApp.ini()
- in CustomSession's constructor do:
WebClientInfo ci = new WebClientInfo(RequestCycle.get());
ci.getProperties().setTimeZone(TimeZone.getTimeZone("GMT"));
setClientInfo(ci);

This way it wont make temp redirect (flash) to the BrowserInfoPage.

If you need more client info props then you'll have to use your code but move it to the constructor of a base page, where a Session exists and all this will work.

> Exception when setting session default timezone with GatherExtendedBrowserInfo
> ------------------------------------------------------------------------------
>
>                 Key: WICKET-3477
>                 URL: https://issues.apache.org/jira/browse/WICKET-3477
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5-RC1
>            Reporter: Bertrand Guay-Paquet
>              Labels: nullpointerexception
>         Attachments: DefaultTimeZone.zip
>
>
> I want to set a default timezone for client sessions so I added the following line at the end of my CustomSession constructor:
> getClientInfo().getProperties().setTimeZone(TimeZone.getTimeZone("GMT"));
> Doing this coupled with getGatherExtendedBrowserInfo() == true however yields a null pointer exception.
> Some analysis:
> In WebSession#getClientInfo(), there is no clientInfo yet and getGatherExtendedBrowserInfo() is true so a redirect is attempted.
> The line "IRequestHandler activeRequestHandler = requestCycle.getActiveRequestHandler();" produces activeRequestHandler == null.
> Since there is no request handler, the following line "String url = requestCycle.urlFor(activeRequestHandler).toString();" gives a null pointer exception as urlFor returns null.
> If getGatherExtendedBrowserInfo() == false, the default timezone set in the Session constructor works fine.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira