Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3956

(nearly) silent failure of filter initialization if struts.action.excludePattern contains invalid regexp

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.3.8
    • Fix Version/s: 2.3.12
    • Component/s: Dispatch Filter
    • Labels:
      None
    • Environment:

      all

      Description

      If the struts.action.excludePatterns constant contains an invalid regexp (for example, it begins with a "*"), the dispatcher can't initialize, but only an "Error filterStart" message will be logged, and the web app won't work. Imho, the expected behavior were a stack trace or a more descriptive error message.

      The cause of the problem: the buildExcludedPatternList() method of org.apache.struts2.dispatcher.ng.InitOperations builds a compiled pattern list of the comma-separated patterns given in this constant with java.util.regex.Pattern.compile() . This emits an IllegalArgumentException or a PatternSyntaxException, if invalid regexp is given, but this exception somewhere silently disappears on his way to the log.

      ---------------

      I suggest to make a minimal example in the documentation:

      ".*\.(css|js|gif|png|jpg|html)$" or "^/static/"

      is what most developer want from this constant. For me took hours to investigate this. Googling for "struts.action.excludePattern" reveals a lot of confusion about this, too. The greatest source of the confusion is that it isn't clear, and isn't anywhere documented, which is the exact regexp syntax here to apply. For example: pattern matching or regular expression, "^" and "$" are valid or not, they are needed or not, "." matches only "." or any character, etc. I think, the original inaccuracy was committed by sun, when they named a class as "Pattern", which operates with regexps. What you here can do, is a single-line minimal-example in the doc, which will explain everything.

      Thank you,

      PH

        Attachments

          Activity

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              hap Peter Horvath
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified