Skip to content

refactor(script): add compiled script caching to GroovyEngine and improve DocBoostMatcher error handling#3074

Merged
marevol merged 2 commits intomasterfrom
refactor/groovy-script-cache-and-boost-error-handling
Mar 15, 2026
Merged

refactor(script): add compiled script caching to GroovyEngine and improve DocBoostMatcher error handling#3074
marevol merged 2 commits intomasterfrom
refactor/groovy-script-cache-and-boost-error-handling

Conversation

@marevol
Copy link
Contributor

@marevol marevol commented Mar 15, 2026

Summary

  • GroovyEngine: Add LRU cache (max 100 entries) for compiled Groovy Script classes to avoid repeated compilation. Each evaluation creates a fresh Script instance for thread-safe binding isolation. GroovyClassLoaders are closed on eviction and via @PreDestroy.
  • DocBoostMatcher: Catch NumberFormatException when parsing boost values, log a warning and return 0.0f instead of propagating the exception.
  • Add comprehensive tests for cache behavior, binding isolation, eviction, concurrent evaluation, close lifecycle, and DocBoostMatcher edge cases.

Test plan

  • Verify existing unit tests pass (mvn test)
  • Verify new cache-related tests pass (GroovyEngineTest)
  • Verify new DocBoostMatcher edge case tests pass
  • Verify concurrent evaluation tests demonstrate thread safety

🤖 Generated with Claude Code

marevol and others added 2 commits March 15, 2026 12:23
…rove DocBoostMatcher error handling

GroovyEngine now caches compiled Groovy Script classes in an LRU map (max 100 entries),
avoiding repeated compilation of the same script text. Each evaluation still creates a
fresh Script instance for thread-safe binding isolation. GroovyClassLoaders are properly
closed on eviction and via @PreDestroy.

DocBoostMatcher now catches NumberFormatException when parsing boost values, logging a
warning and returning 0.0f instead of propagating the exception.

Includes comprehensive tests for cache behavior, binding isolation, eviction, concurrent
evaluation, close lifecycle, and new DocBoostMatcher edge cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… in GroovyEngine

Replace the manual synchronized LinkedHashMap-based LRU cache with Guava
Cache for compiled Groovy scripts. This provides segment-based locking
for lock-free concurrent reads and automatic eviction via RemovalListener.
Also makes scriptCacheSize and maxScriptLogLength configurable via DI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@marevol marevol self-assigned this Mar 15, 2026
@marevol marevol added this to the 15.6.0 milestone Mar 15, 2026
@marevol marevol merged commit 5468e4c into master Mar 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant