You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Martin Grigorov <mg...@apache.org> on 2012/09/24 16:47:20 UTC

WICKET-4780

Hi,

https://issues.apache.org/jira/browse/WICKET-4780 shows an interesting
problem with wrapping of request mappers.

The code is:
public void init() {
  super.init();
  setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this));
  mountPage("/home", HomePage.class);
}

and this leads to:
BufferedResponseMapper is wrapped as part of SystemMapper in CryptoMapper.
Later when mountPage("/home") is called a new CompoundRequestMapper is
created with CryptoMapper as a member and a MountedMapper for HomePage
is prepended to it.
So we have : CompoundRequestMapper(MountedMapper(/home),
CryptoMapper(SystemMapper(BufferedResponseMapper, /* other system
mappers */ )))

When a request with url : home?0 comes MountedMapper(/home) is asked
first and it matches, so BufferedResponseMapper is not asked at all.
Later when starting to render the reported WARN is issued because now
we check for stored response.


The only solution that I see is to do smarter wrapping at
#setRootRequestMapper().
We can split SystemMapper on two sub mappers - one with
RestartResponseAtInterceptPageException.MAPPER and
BufferedResponseMapper (BRM),and another with the rest system mappers
which are also used to generate Urls.
When #setRootRequestMapper() is called we should create such compound
mapper that will always use RRAIPE.MAPPER and BRM before any other
mapper.

Do you see other solutions which are simpler than this one ?

-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Re: WICKET-4780

Posted by Martin Grigorov <mg...@apache.org>.
Fixed it by delegating CryptoMapper#getCompatibilityScore() to the
wrapped mapper.
Sounds a bit strange because most of the time the request url will be
still encrypted and most of the user's mappers wont match but even in
this case BufferedResponseMapper will match.

On Mon, Sep 24, 2012 at 7:29 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> that class used to have a javadoc that specified it was important that
> it is the last mount-related call in init()
>
> -igor
>
> On Mon, Sep 24, 2012 at 7:47 AM, Martin Grigorov <mg...@apache.org> wrote:
>> Hi,
>>
>> https://issues.apache.org/jira/browse/WICKET-4780 shows an interesting
>> problem with wrapping of request mappers.
>>
>> The code is:
>> public void init() {
>>   super.init();
>>   setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this));
>>   mountPage("/home", HomePage.class);
>> }
>>
>> and this leads to:
>> BufferedResponseMapper is wrapped as part of SystemMapper in CryptoMapper.
>> Later when mountPage("/home") is called a new CompoundRequestMapper is
>> created with CryptoMapper as a member and a MountedMapper for HomePage
>> is prepended to it.
>> So we have : CompoundRequestMapper(MountedMapper(/home),
>> CryptoMapper(SystemMapper(BufferedResponseMapper, /* other system
>> mappers */ )))
>>
>> When a request with url : home?0 comes MountedMapper(/home) is asked
>> first and it matches, so BufferedResponseMapper is not asked at all.
>> Later when starting to render the reported WARN is issued because now
>> we check for stored response.
>>
>>
>> The only solution that I see is to do smarter wrapping at
>> #setRootRequestMapper().
>> We can split SystemMapper on two sub mappers - one with
>> RestartResponseAtInterceptPageException.MAPPER and
>> BufferedResponseMapper (BRM),and another with the rest system mappers
>> which are also used to generate Urls.
>> When #setRootRequestMapper() is called we should create such compound
>> mapper that will always use RRAIPE.MAPPER and BRM before any other
>> mapper.
>>
>> Do you see other solutions which are simpler than this one ?
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Re: WICKET-4780

Posted by Igor Vaynberg <ig...@gmail.com>.
that class used to have a javadoc that specified it was important that
it is the last mount-related call in init()

-igor

On Mon, Sep 24, 2012 at 7:47 AM, Martin Grigorov <mg...@apache.org> wrote:
> Hi,
>
> https://issues.apache.org/jira/browse/WICKET-4780 shows an interesting
> problem with wrapping of request mappers.
>
> The code is:
> public void init() {
>   super.init();
>   setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this));
>   mountPage("/home", HomePage.class);
> }
>
> and this leads to:
> BufferedResponseMapper is wrapped as part of SystemMapper in CryptoMapper.
> Later when mountPage("/home") is called a new CompoundRequestMapper is
> created with CryptoMapper as a member and a MountedMapper for HomePage
> is prepended to it.
> So we have : CompoundRequestMapper(MountedMapper(/home),
> CryptoMapper(SystemMapper(BufferedResponseMapper, /* other system
> mappers */ )))
>
> When a request with url : home?0 comes MountedMapper(/home) is asked
> first and it matches, so BufferedResponseMapper is not asked at all.
> Later when starting to render the reported WARN is issued because now
> we check for stored response.
>
>
> The only solution that I see is to do smarter wrapping at
> #setRootRequestMapper().
> We can split SystemMapper on two sub mappers - one with
> RestartResponseAtInterceptPageException.MAPPER and
> BufferedResponseMapper (BRM),and another with the rest system mappers
> which are also used to generate Urls.
> When #setRootRequestMapper() is called we should create such compound
> mapper that will always use RRAIPE.MAPPER and BRM before any other
> mapper.
>
> Do you see other solutions which are simpler than this one ?
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com