Uploaded image for project: 'Tiles Autotag'
  1. Tiles Autotag
  2. AUTOTAG-21

AbstractModelBody.evaluateAsString uses regular expression to replace the contents of the string. It should be able to use a pre compiled Pattern instead for performance reason

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1.0
    • 1.2.0
    • None

    Description

      I am seeing high CPU utilization on AbstractModelBody.evaluateAsString method in my thread dumps.

      java.lang.Thread.State: RUNNABLE
      at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
      at java.util.regex.Pattern$Curly.match0(Pattern.java:4158)
      at java.util.regex.Pattern$Curly.match(Pattern.java:4132)
      at java.util.regex.Pattern$Branch.match(Pattern.java:4502)
      at java.util.regex.Pattern$Start.match(Pattern.java:3408)
      at java.util.regex.Matcher.search(Matcher.java:1199)
      at java.util.regex.Matcher.find(Matcher.java:592)
      at org.apache.tiles.autotag.core.runtime.AbstractModelBody.evaluateAsString(AbstractModelBody.java:70)
      at org.apache.tiles.template.PutAttributeModel.execute(PutAttributeModel.java:96)
      at org.apache.tiles.jsp.taglib.PutAttributeTag.doTag(PutAttributeTag.java:226)

      What I did

      1. Declared a compiled Pattern

      private static Pattern pattern = Pattern.compile("^\\s*|
      s*$");

      2. in evaluateAsString :
      pattern.matcher(body).replaceAll("");

      Attachments

        1. AbstractModelBody.patch
          1 kB
          Gagan Arora

        Activity

          People

            mck Michael Semb Wever
            gaganarora77 Gagan Arora
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: