critical
#29465
React form: <size-constraint> without an upper bound rejects every non-empty text
An attribute annotated with a bare <size-constraint> cannot be given any value in a React form. Every non-empty text is reported as too long (maximum length: -1). Affects 8.0.0-alpha7 as a blocker for React forms. Root cause: TLSize.NO_UPPER_BOUND (Long.MAX_VALUE) truncated to int (-1) in AttributeOperations.getUpperBound().
Migration
The fix changes how "no upper bound" is encoded in three public APIs. Applications that evaluated the former values must be adjusted.
AttributeOperations.getUpperBound()
A size annotation without an upper bound is now reported as Integer.MAX_VALUE. Before, the long sentinel TLSize.NO_UPPER_BOUND was truncated to -1. Application code that treated -1 as "no limit" must be changed:
{{{#!java // before if (AttributeOperations.getUpperBound(size) == -1) {
// no upper bound
}
// after if (AttributeOperations.getUpperBound(size) == Integer.MAX_VALUE) {
// no upper bound
} }}}
getLowerBound() saturates the same way, but is not affected in practice, since TLSize.NO_LOWER_BOUND is 0 and was never truncated.
AttributeOperations.getLength()
Returns null instead of -1, if the size annotation declares no upper bound. Code that assigns the result to an int now fails with a NullPointerException:
{{{#!java // before int length = AttributeOperations.getLength(part); // -1, if no upper bound
// after Integer length = AttributeOperations.getLength(part); // null, if no upper bound if (length != null) {
...
} }}}
StringLengthConstraint
The constructors normalize a maxLength of Integer.MAX_VALUE to the new constant StringLengthConstraint.NO_LIMIT (-1), because such a bound can never be violated: String.length() is an int. For an unbounded constraint, hasMaxLength() therefore returns false and getMaxLength() returns NO_LIMIT. The validation behaviour is unchanged.
Applications that explicitly passed Integer.MAX_VALUE and evaluated hasMaxLength() or getMaxLength() now see "no limit" instead of a limit of 2147483647. Use the constant StringLengthConstraint.NO_LIMIT instead of a literal -1 to express an unenforced bound.