Skip to content

Wrong compareTo() implementation in Portlet mapping predicates [SPR-9605] #14239

@spring-projects-issues

Description

@spring-projects-issues

Ondřej Životský opened SPR-9605 and commented

I have 3 controllers for one portlet:

@Controller @RequestMapping(value="VIEW")
public class ControllerX {...}
@Controller @RequestMapping(value="VIEW", params={"myParamMode=1"})
public class Controller1 {...}
@Controller @RequestMapping(value="VIEW", params={"myParamMode=2"})
public class Controller2 {...}

If I deploy application to localhost (Win7, Java7, Liferay 6.1 on Tomcat7) everything works fine.
If I deploy application to my TEST server (CentOS, Java6, Liferay 6.1 on Tomcat7) all requests are forwarded to ControllerX ("myParamMode" parameter is ignored).

I debugged org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping and I thing the problem is compareTo() methods in TypeLevelMappingPredicate, RenderMappingPredicate, ResourceMappingPredicate, ...
The predicates are sorted in org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping.getHandlerInternal(): Collections.sort(predicates);

The sorting is called in this order (my TEST server):

renderPredicate.compareTo(resPredicate1) returns *0*
resPredicate1.compareTo(resPredicate2) returns *0*
resPredicate2.compareTo(tlPredicate1) returns *-1*
tlPredicate1.compareTo(tlPredicate2) returns *0*

So, sorting result is:

DefaultAnnotationHandlerMapping$RenderMappingPredicate
DefaultAnnotationHandlerMapping$ResourceMappingPredicate1
DefaultAnnotationHandlerMapping$ResourceMappingPredicate2
DefaultAnnotationHandlerMapping$TypeLevelMappingPredicate1
DefaultAnnotationHandlerMapping$TypeLevelMappingPredicate2

I expected order:

DefaultAnnotationHandlerMapping$ResourceMappingPredicate1
DefaultAnnotationHandlerMapping$ResourceMappingPredicate2
DefaultAnnotationHandlerMapping$TypeLevelMappingPredicate1
DefaultAnnotationHandlerMapping$TypeLevelMappingPredicate2
DefaultAnnotationHandlerMapping$RenderMappingPredicate

because RenderMappingPredicate (my class ControllerX) match all requests.


Affects: 3.1.1

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions