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

Peter Ertl commented on WICKET-4270:
------------------------------------

originally we had this:

        // see if request handler addresses the resource we serve
                if 
(resourceReference.getResource().equals(handler.getResource()) == false)
                {
                        return null;
                }

then there came WICKET-3506 and Igor changed this location to:

                // see if request handler addresses the resource we serve
                if (resourceReference.equals(handler.getResourceReference()) == 
false &&
                        
resourceReference.getResource().equals(handler.getResource()) == false)
                {
                        return null;
                }

the commit message tells us:

   " added equals/hashcode to some iresource impls. change resource mapper to 
compare resourcereferences 
   " as well as iresource instances for better matching. Issue: WICKET-3506

So far and after reading WICKET-3506 this makes sense for me...

The option for improvement would be to just compare ResourceReference with 
equals()

This would require a properly working ResourceReference#equals()

The current ResourceReference#equals() works by comparing the resource key:

        public final static class Key implements Serializable
        {
             // .......
                final String scope;
                final String name;
                final Locale locale;
                final String style;
                final String variation;
             // .........
          }

Since all descendant classes of ResourceReferences must provide a valid key 
equals should probably always work as expected.

I don't want to suggest this before Igor gave us his opinion, but basically 
just comparing ResourceReference should be fine *imho*
                
> Mounted ResourceReference getResource() method being called for requests that 
> do not match the mounted name
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4270
>                 URL: https://issues.apache.org/jira/browse/WICKET-4270
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.3
>            Reporter: Philip McCullick
>         Attachments: resource_example.zip
>
>
> The getResource() method is being called for a mounted ResourceReference even 
> when the url does not match. So far it seems to only happen when some wicket 
> Ajax is included in the page. To get around the problem, I've added a  check 
> on my ResourceReference that looks for the mounted name in the request url 
> but it seems like the mounting should handle that. 
> To reproduce the error:
> 1. Call mountResource("uploadedfiles", MyResourceReference.class);
> 2. Add an AjaxFallbackLink to a page
> 3. In MyResourceReference getResource() method return null;
> 4. Run the application and open the page with an AjaxFallbackLink and you 
> will get 
> java.lang.NullPointerException
> at 
> org.apache.wicket.request.mapper.ResourceMapper.mapHandler(ResourceMapper.java:167)
> at 
> org.apache.wicket.request.mapper.CompoundRequestMapper.mapHandler(CompoundRequestMapper.java:156)
> at 
> org.apache.wicket.request.cycle.RequestCycle.mapUrlFor(RequestCycle.java:401)
> at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:485)
> at 
> org.apache.wicket.markup.html.internal.HeaderResponse.renderJavaScriptReference(HeaderResponse.java:205)
> ...
> The class org.apache.wicket.request.mapper.ResourceMap calls the 
> getResource() (line 167) method even though the url does not match the 
> mounted name. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to