Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1740

Predicate Language parsing fails on semi-colon before "else" keyword

XMLWordPrintable

      The appropriate use of semi colons after a handler is not clear.  The docs say:

      http://undertow.io/undertow-docs/undertow-docs-2.0.0/#textual-representation-of-handlers

      Handlers are executed in order and separated by line breaks or semi colons.
      

      This implies that a semicolon should always be valid after a handler.  The semi colon is certainly optional as shown after the first handler here: 

      path(/foo) -> response-code(404) else response-code(503);
      

       And a semi colon is allowed when the first handler is encased in curly braces: 

      path(/foo) -> { response-code(404); } else { response-code(503); }
      

      However, this example throws a parsing error: 

      path(/foo) -> response-code(404); else response-code(503);
      

      With the error: 

      Error parsing predicated handler string Invalid expression
      

      I think that last example should be valid since the next text after the first handler is "else".  I've been caught off guard a few times when I put semi colons after handlers, but then I have an example like above and receive a parsing error.  It doesn't seem necessary to need to use the curly braces unless I have more than one handler I want to group together. 

      The predicate DSL is clearly borrowing from most scripting languages like Java or JS where pseudo code like this would be valid: 

      if( condition )
        doSomething();
      else
        doElse();

      In that pseudo code, the first semi colon doesn't terminate the entire if statement, so it doesn't seem correct that the Undertow Predicate language treats it that way.

       

              rhn-cservice-bbaranow Bartosz Baranowski
              bdw429s Brad Wood
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: