Skip to content

Conversation

@jasmith-hs
Copy link
Contributor

Replaced the error-prone CallStack and Stack pop/push pattern with AutoCloseable so that pushing can be done using try-with-resources.

Added method dangerouslyGetWithoutClosing() to allow backward-compatibility with existing public methods.

Migrated all of the prod code, and the test code using CallStack pushing. Many tests using JinjavaInterpreter.pushCurrent() still need/can be migrated.

Using algebra Result for correct/explicit error handling.

New methods like AutoCloseableSupplier<Result<String, TagCycleException>> closeablePush(...), and deprecated the old methods that don't return an AutoCloseableSupplier<T>.

The way that I designed AutoCloseableSupplier and AutoCloseableImpl makes it so that you can use .map to transform what the autocloseable is, and a custom consumer is supplied that tells how to "close" the thing. And in cases where no closing needs to occur (such as error cases where nothing is pushed to a stack), there's AutoCloseableSupplier.of(value)

@jasmith-hs jasmith-hs merged commit d15d7c0 into master Jul 17, 2025
3 checks passed
@jasmith-hs jasmith-hs deleted the auto-closables branch July 17, 2025 13:57
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.

3 participants