Improve diagnostics when repeated text size calculation results in overflow in SpEL #31341
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
If the resulting size of repeated text in a SpEL expression (using the repeat operator
*
) would exceedMAX_REPEATED_TEXT_SIZE
, we currently throw aSpelEvaluationException
with theMAX_REPEATED_TEXT_SIZE_EXCEEDED
message.However, if the calculation of the repeated text size results in integer overflow, our max size check fails to detect that, and
String#repeat(int)
throws a preemptiveOutOfMemoryError
from which the application immediately recovers.To improve diagnostics for users, we should ensure that we consistently throw a
SpelEvaluationException
with theMAX_REPEATED_TEXT_SIZE_EXCEEDED
message when integer overflow occurs.The text was updated successfully, but these errors were encountered: