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

Max and Min content size predicates are implemented backwards

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.2.0.Final
    • 2.1.3.Final
    • None
    • None

      These two predicates from undertow are named/implemented backwards.  The "max" should be ensuring the provided value is at least as small or smaller and the "min" should be ensuring the provided value is at least as big or bigger.  But here are the descriptions of each one.

      MinContentSizePredicate

      Predicate that returns true if the Content-Size of a request is below a given value.

       
      MaxContentSizePredicate

      Predicate that returns true if the Content-Size of a request is above a given value.

       So to spell it out, if someone uses the following predicate: 

      max-content-size(5)

       That means they are saying the maximum content size is 5 bytes.  So, here's a quick truth table:

      • If content length is 4 bytes -> should return true (under the max)
      • if content length is 5 bytes -> should return true (at the max, but not over)
      • if content length is 6 bytes -> should return false (over the max)

      But this is the exact opposite of how these predicates have been implemented.  The javadoc matches the behavior, but not the name.
       
      In order to avoid a breaking change how about we deprecate these, and replace them with 'request-larger-than' and 'request-smaller-than' to make it clearer exactly what is being tested 
       

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              bdw429s Brad Wood
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: