Skip to content

Improve public API and restore 2.x backward compatibility#40

Open
chbloemer wants to merge 5 commits intomasterfrom
claude/practical-saha
Open

Improve public API and restore 2.x backward compatibility#40
chbloemer wants to merge 5 commits intomasterfrom
claude/practical-saha

Conversation

@chbloemer
Copy link
Copy Markdown
Contributor

Summary

  • Restore backward compatibility: Re-add missing PugTemplate.process(PugModel, Writer) method (deprecated) that was removed but still used by 2.4.1 consumers
  • Fix resource leak: templateExists() in both PugEngine and PugConfiguration now properly closes the Reader via try-with-resources
  • Add convenience API: New PugEngine.render(String templateName, Map model) methods that combine getTemplate() + render() in a single call
  • Remove duplicate caching: PugConfiguration no longer maintains its own Caffeine cache — it delegates entirely to PugEngine, eliminating double-caching and simplifying the code
  • Simplify expressionCacheSize: Now works with all expression handlers (not just JexlExpressionHandler), removing the IllegalStateException for GraalJS users

Test plan

  • All 941 tests pass (mvn test)
  • Verify a 2.4.1 consumer project still compiles against 3.0.0
  • Verify PugConfiguration-based code paths still work end-to-end

🤖 Generated with Claude Code

chbloemer and others added 5 commits April 16, 2026 09:52
- Restore missing PugTemplate.process(PugModel, Writer) method as
  deprecated to maintain backward compatibility with 2.4.1
- Fix resource leak in templateExists() (PugEngine and PugConfiguration)
  where Reader was never closed
- Add convenience render(String, Map) methods to PugEngine for
  combined getTemplate + render in a single call
- Remove duplicate caching in PugConfiguration by delegating entirely
  to PugEngine (was maintaining its own Caffeine cache separately)
- Simplify expressionCacheSize handling to work with all expression
  handlers, not just JexlExpressionHandler

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add validation for negative expressionCacheSize in PugConfiguration
- Restore testSetExpressionCacheSizeNegative test
- Remove redundant expressionHandler.setCache() call in setCaching()
- Add thread-safety note to class comment
- Remove stray blank line

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use volatile + double-checked locking for the cached PugEngine
instance instead of just documenting the race condition.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use pattern matching instanceof across compiler, parser, and utilities
- Convert Attr and AttributeValueResponse to records
- Replace mutable HashMap with Map.of() in Doctypes
- Fix StringBuffer -> StringBuilder in PugException
- Optimize StringBuilder initialization in Compiler
- Add TODO for sealed Token hierarchy when migrating to Java 21

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

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant