Spring Framework
  1. Spring Framework
  2. SPR-9605

Wrong compareTo() implementation in Portlet mapping predicates

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Complete
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.3, 3.2 M2
    • Component/s: Web:Portlet
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      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.

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              Ondřej Životský
              Last updater:
              Chris Beams
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 40 weeks ago