Spring Framework
  1. Spring Framework
  2. SPR-7787

Qualifiers in regular expressions in @RequestMapping do not work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 3.0.5
    • Fix Version/s: 3.1 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      One can use regular expression to narrow a path in a RequestMapping, which is nice.

      Unfortunate a regex with a quantifier like

      @RequestMapping("/

      {user}

      /{year:
      d{1,4}}")

      leeds to the following exception:

      org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.util.regex.PatternSyntaxException: Unclosed counted closure near index 7
      (\d{1,4)\Q}\E
             ^
      

      Full stack is attached.

      Thanks and kind regards.

      1. AntPathStringMatcher.java
        5 kB
        Mike
      2. antpathstringmatcher-patch.diff
        8 kB
        Mike
      3. AntPathStringMatcher-v2.patch
        2 kB
        Mike
      4. stacktrace.txt
        10 kB
        Michael Simons

        Activity

        Hide
        Bojan Tomic added a comment -

        I'm using 3.1.0.RELEASE and still see this problem, even though Fix Version is listed as 3.1 RC1.
        What's the catch?

        Show
        Bojan Tomic added a comment - I'm using 3.1.0.RELEASE and still see this problem, even though Fix Version is listed as 3.1 RC1. What's the catch?
        Hide
        Rossen Stoyanchev added a comment -

        I would start with trying 3.1.4.RELEASE (released today) but other than that help to demonstrate the issue. You can use the repro repository. If you still see the issue, open a new ticket with an updated description. This one cannot be reopened.

        Show
        Rossen Stoyanchev added a comment - I would start with trying 3.1.4.RELEASE (released today) but other than that help to demonstrate the issue. You can use the repro repository . If you still see the issue, open a new ticket with an updated description. This one cannot be reopened.
        Hide
        Bojan Tomic added a comment -

        Tried with 3.1.4.RELEASE.
        This is what I want to do:

        UriTemplate temp = new UriTemplate("/sample/{id:
        d{2}}");
        System.out.println(temp.match("/sample/12"));

        Tried escaping the curly brackets in every way I could think of, but nothing has effect. Seems like the group gets terminated on the very first encountered closing bracket.
        Should this work or am I at fault here?

        If this is indeed a bug, I can put a sample to repro repo I guess.

        Show
        Bojan Tomic added a comment - Tried with 3.1.4.RELEASE. This is what I want to do: UriTemplate temp = new UriTemplate("/sample/{id: d{2}}"); System.out.println(temp.match("/sample/12")); Tried escaping the curly brackets in every way I could think of, but nothing has effect. Seems like the group gets terminated on the very first encountered closing bracket. Should this work or am I at fault here? If this is indeed a bug, I can put a sample to repro repo I guess.
        Hide
        Bojan Tomic added a comment -

        Sorry, forgot to format code and I can't edit the comment now. This is what I wanted to post:

        UriTemplate temp = new UriTemplate("/sample/{id:\\d{2}}");
        System.out.println(temp.match("/sample/12"));
        
        Show
        Bojan Tomic added a comment - Sorry, forgot to format code and I can't edit the comment now. This is what I wanted to post: UriTemplate temp = new UriTemplate( "/sample/{id:\\d{2}}" ); System .out.println(temp.match( "/sample/12" ));
        Hide
        Rossen Stoyanchev added a comment -

        Bojan Tomic, start by taking a look at this test. It seems to do what you're trying to do.

        Show
        Rossen Stoyanchev added a comment - Bojan Tomic , start by taking a look at this test . It seems to do what you're trying to do.

          People

          • Assignee:
            Rossen Stoyanchev
            Reporter:
            Michael Simons
            Last updater:
            Rossen Stoyanchev
          • Votes:
            7 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 10 weeks, 6 days ago