From 8c468636fb77ee273db0d2f80e7416ce119fdc5a Mon Sep 17 00:00:00 2001 From: Blaz Snuderl Date: Thu, 23 Apr 2026 09:30:00 +0200 Subject: [PATCH] Fix cache key mismatch in RuleCache.compileRule The descriptorMap lookup at the top of compileRule() used fieldDescriptor (the user's field), but the corresponding store at the bottom uses ruleFieldDesc (the rule field, e.g. StringRules.pattern). The read therefore always missed, and cached CelRules were never reused across different user fields that share the same predefined rule. Use ruleFieldDesc for the lookup so it matches the store. --- src/main/java/build/buf/protovalidate/RuleCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/build/buf/protovalidate/RuleCache.java b/src/main/java/build/buf/protovalidate/RuleCache.java index 44497dae..8cec0c0d 100644 --- a/src/main/java/build/buf/protovalidate/RuleCache.java +++ b/src/main/java/build/buf/protovalidate/RuleCache.java @@ -144,7 +144,7 @@ List compile( FieldDescriptor ruleFieldDesc, Message message) throws CompilationException { - List celRules = descriptorMap.get(fieldDescriptor); + List celRules = descriptorMap.get(ruleFieldDesc); if (celRules != null) { return celRules; }