Spring Framework
  1. Spring Framework
  2. SPR-8355

AntPatternComparator prefers a less specific match when brackets occur

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.4, 3.0.5
    • Fix Version/s: Waiting for Triage
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      When sorting the following array: [/a/b/

      {c}/**, /a/b/{c}

      /*/, /, //] with the current implementation of AntPathMatcher.AntPatternComparator, the sort order results in: [//, /*, /a/b/

      {c}/**/, /a/b/{c}

      /**] . In our case, this results in the wrong controller picking up the request.

      I believe the problem lies in this block:
      if (totalCount1 != totalCount2) {
      return totalCount1 - totalCount2;
      }
      and would be correct if instead it returned "totalCount2 - totalCount1;". However, I can't speak to how this may affect other use cases.

        Issue Links

          Activity

          Hide
          Alex Antonov added a comment -

          It seems that the brackets should be weighted differently, when compared to the wildcards. Also the number of URL path segments should be used to compare.

          Show
          Alex Antonov added a comment - It seems that the brackets should be weighted differently, when compared to the wildcards. Also the number of URL path segments should be used to compare.

            People

            • Assignee:
              Juergen Hoeller
              Reporter:
              Johnathon
              Last updater:
              Chris Beams
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                2 years, 30 weeks, 5 days ago