Repository navigation
Conversation
ELFacade ran a look-behind regular expression with over a hundred
alternations across every message containing "${" to disarm unescaped
"#{" sequences. It dominated the cost of any violation whose message
uses EL, including several built-in default messages. A direct scan
gives the same result and returns immediately when there is no "#{".
A hand-written matcher equivalent to DEFAULT_EMAIL_PATTERN replaces running the regular expression for @Email without a custom regexp.
…engine Without flags, .* matches exactly the values that contain no line terminator, so look for those instead of running the pattern.
- Cache fully interpolated messages that contain no EL expression, as they do not depend on the validated value. - Key interpolation caches on the identity of the constraint's attribute map, which descriptors hand out as a stable instance, instead of hashing and comparing the whole map. - Memoize the constraint message template instead of reading it reflectively from the annotation for every violation.
tandraschko
reviewed
Oct 5, 2026
| resolvedMessage = replaceAnnotationAttributes(resolvedMessage, annotationParameters); | ||
|
|
||
| // EL handling | ||
| // EL handling; the evaluator leaves messages without "${" untouched |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the cost of the built-in constraints and of message interpolation, which dominate any validation that produces violations.
Evidence
Numbers are JMH throughput (
-p provider=bval -f 2 -wi 2 -i 3, 1 s iterations,-prof gc, JDK 25), measured against the PR below this one. The machine was busy, so throughput carries wide error bars; the bytes allocated per operation (B/op) are deterministic.All benchmarks
Tests:
bval-jsr unit tests: 255 run, 0 failures · TCK: 1070 run, 0 failures, 1 skipped
Merge Danger
Door: two-way
Blast Radius: messages
#{. The test pins master's exact outputs, including escaped forms.@Emailwithout a custom regexp: the matcher must accept exactly whatDEFAULT_EMAIL_PATTERNdoes. It's fuzzed against the regex.clearCache()clears it.