Uploaded image for project: 'Spring Tool Suite'
  1. Spring Tool Suite
  2. STS-1773

@PathVariable validation for @RequestMapping doesn't work well if URI template contains custom regular expression (warning message says: 'URI template variable "systemId:\d+" is not defined')

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.1.RELEASE, 2.7.0.M1
    • Fix Version/s: None
    • Component/s: EDITING, VALIDATION
    • Labels:
    • Environment:
      Linux neso 2.6.35-28-generic-pae #50-Ubuntu SMP Fri Mar 18 20:43:15 UTC 2011 i686 GNU/Linux
      java version "1.6.0_23" \ Java(TM) SE Runtime Environment (build 1.6.0_23-b05) \ Java HotSpot(TM) Server VM (build 19.0-b09, mixed mode)

      Description

      Problem is not only warning message 'URI template variable "systemId:\d+" is not defined',
      but it seems to that validation consumes almost 100% of CPU while I have opened Java Editor with my controller.

      I found in documentation http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html that defining URI template with custom regular expression is possible:

      By default, the URI template will match against the regular expression [^\.]* (i.e. any character other than period), but this can be changed by specifying another regular expression, like so: /hotels/{hotel:\d+}.

      Here is snapshot of my controller's request handler method:

      	@RequestMapping("system-{systemId:\\d+}/report_{width}x{height}.png")
      	public void rendeCustomChart(
      			@PathVariable String systemId,
      			@PathVariable int width,
      			@PathVariable int height,
      			HttpServletResponse response)
      	throws IOException, ParseException {
       
      		ImageSize imageSize = new ImageSize(width, height);
      		response.setContentType("image/png");
      		chartProvider.writeCustomChartToStream(systemId, imageSize, response.getOutputStream());
      	}

        Activity

        Hide
        mlippert Martin Lippert added a comment -

        Hey Milan!

        Thanks for reporting this! Sounds like bug we need to fix...
        Are you able to reproduce this all the time when opening the Java editor for this? If so, it would be great if you could take a thread dump while you see this 100% CPU period and attach that to this issue. That would be awesome!

        (Run jps to get a list of all java processes running on your system. And then jstack on the specific process to print the stack.)

        Thanks!
        -Martin

        Show
        mlippert Martin Lippert added a comment - Hey Milan! Thanks for reporting this! Sounds like bug we need to fix... Are you able to reproduce this all the time when opening the Java editor for this? If so, it would be great if you could take a thread dump while you see this 100% CPU period and attach that to this issue. That would be awesome! (Run jps to get a list of all java processes running on your system. And then jstack on the specific process to print the stack.) Thanks! -Martin
        Hide
        thon Terry Denney added a comment -

        Hi Milan,

        I have fixed the validation problem with the regular expression. This fix should be avaiable in the next milestone release, but it will still be useful to see the stack trace when it consumes 100% of your CPU to make sure there is no other problems with the validation.

        Thanks!
        Terry

        Show
        thon Terry Denney added a comment - Hi Milan, I have fixed the validation problem with the regular expression. This fix should be avaiable in the next milestone release, but it will still be useful to see the stack trace when it consumes 100% of your CPU to make sure there is no other problems with the validation. Thanks! Terry
        Hide
        milan.skuhra Milan Skuhra added a comment - - edited

        Hi Martin,

        yes I'am able reproduce it (it happens every time). Here are thread dumps (two attempts).
        While I was dumping 'top' shows me that same process was consuming around 60% of CPU (I had open only one Java Editor with my controller).

        One more thing. I needed do some modification and save changes to reproduce that behavior. When I close and open same java file CPU consumption was OK until next saving.

        Show
        milan.skuhra Milan Skuhra added a comment - - edited Hi Martin, yes I'am able reproduce it (it happens every time). Here are thread dumps (two attempts). While I was dumping 'top' shows me that same process was consuming around 60% of CPU (I had open only one Java Editor with my controller). One more thing. I needed do some modification and save changes to reproduce that behavior. When I close and open same java file CPU consumption was OK until next saving.
        Hide
        thon Terry Denney added a comment -

        It seems like the high CPU usage might be caused by UAA monitoring. I've opened a new Jira issue to track the performance and closing this task as the initial validation is now fixed.

        STS-1808: Investigate high CPU usage (likely from UAA monitor)
        https://issuetracker.springsource.com/browse/STS-1808

        Show
        thon Terry Denney added a comment - It seems like the high CPU usage might be caused by UAA monitoring. I've opened a new Jira issue to track the performance and closing this task as the initial validation is now fixed. STS-1808 : Investigate high CPU usage (likely from UAA monitor) https://issuetracker.springsource.com/browse/STS-1808

          People

          • Assignee:
            thon Terry Denney
            Reporter:
            milan.skuhra Milan Skuhra
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: