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

Predicate Language cannot set attribute to empty string

XMLWordPrintable

      The following predicate handler, 

      set( attribute=%{i,X-Tomcat-DocRoot}, value='' ) 

      produces a nasty parsing exception 

      java.lang.StringIndexOutOfBoundsException: index -1,length 0
              at java.base/java.lang.String.checkIndex(Unknown Source)
              at java.base/java.lang.AbstractStringBuilder.charAt(Unknown Source)
              at java.base/java.lang.StringBuilder.charAt(Unknown Source)
              at io.undertow.server.handlers.builder.PredicatedHandlersParser.tokenize(PredicatedHandlersParser.java:617)
              at io.undertow.server.handlers.builder.PredicatedHandlersParser.parse(PredicatedHandlersParser.java:84)
      

      It doesn't seem that the parser was designed to handle the simple scenario of empty quotes!  

      Leaving off the `value` parameter from the handler parses OK,

      set( attribute=%{i,X-Tomcat-DocRoot} ) 

      but throws an NPE when the handler actually runs:

      java.lang.NullPointerException: null
              at io.undertow.server.handlers.SetAttributeHandler.handleRequest(SetAttributeHandler.java:117)
              at io.undertow.predicate.PredicatesHandler.handleRequest(PredicatesHandler.java:113)

      The expected behavior for both of these examples would be to initialize the attribute (an HTTP request header in this case) to an empty value.

       

            rhn-support-rmartinc Ricardo Martin Camarero
            bdw429s Brad Wood (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: