You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org> on 2011/02/23 23:12:38 UTC

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

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
         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

        

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

Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Guay-Paquet closed WICKET-3477.
----------------------------------------


> 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-core
>    Affects Versions: 1.5-RC1
>            Reporter: Bertrand Guay-Paquet
>            Assignee: Martin Grigorov
>              Labels: nullpointerexception
>             Fix For: 1.4.17, 1.5-RC3
>
>         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

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

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov reassigned WICKET-3477:
---------------------------------------

    Assignee: Martin Grigorov

> 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
>            Assignee: Martin Grigorov
>              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

        

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

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
    [ 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

        

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

Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998861#comment-12998861 ] 

Bertrand Guay-Paquet commented on WICKET-3477:
----------------------------------------------

Thank you Martin for the excellent explanation.

I did not know setClientInfo() existed which allowed me to create the WebClientInfo instance myself.

Should I put that as "resolved" then?

> 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
>            Assignee: Martin Grigorov
>              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

        

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

Posted by "Bertrand Guay-Paquet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998861#comment-12998861 ] 

Bertrand Guay-Paquet edited comment on WICKET-3477 at 2/24/11 2:28 PM:
-----------------------------------------------------------------------

Thank you Martin for the excellent explanation.

I did not know setClientInfo() existed which allowed me to create the WebClientInfo instance myself.

Should I put that as "resolved" then?

(for the record, the only information I could find for setting default ClientInfo values was : http://apache-wicket.1842946.n4.nabble.com/Using-ClientProperties-Object-for-User-selectable-Timezone-td1846293.html)

      was (Author: berniegp):
    Thank you Martin for the excellent explanation.

I did not know setClientInfo() existed which allowed me to create the WebClientInfo instance myself.

Should I put that as "resolved" then?
  
> 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
>            Assignee: Martin Grigorov
>              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

        

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

Posted by "Martin Grigorov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-3477.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.5-RC3
                   1.4.17

With r1075014 (1.4.x) and r1075014 (1.5.x) a javadoc is added explaining that getClientInfo() should not be called in Session constructor.

> 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
>            Assignee: Martin Grigorov
>              Labels: nullpointerexception
>             Fix For: 1.4.17, 1.5-RC3
>
>         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