Skip to content

Introduce feature flag for auto-closing AutoCloseable in Jupiter's ExtensionContext.Store #4434

@marcphilipp

Description

@marcphilipp

Currently, only instances of CloseableResource that are stored in an ExtensionContext.Store are closed automatically when the ExtensionContext is closed. However, items stored in the session-/request-level stores only need to implement AutoCloseable. To address this confusing difference in behavior, we should introduce a configuration parameter that allows to treat AutoCloseable like CloseableResource in Jupiter's stores. It should be "on" by default in 5.13.

Deliverables

  • Introduce configuration parameter for enabling auto-closing AutoCloseable objects (true by default)
  • Deprecate CloseableResource
  • Make CloseableResource extend AutoCloseable so existing implementations would keep working Doesn't work because CloseableResource#close is allowed to throw Throwable, not just Exception
  • Log warning if an object is put into encountered while closing the Store that implements CloseableResource but not AutoCloseable (if the feature is on)
  • Document migration path for external extensions (implement both CloseableResource and AutoCloseable should they need to support pre-5.13 versions)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions