Skip to content

Commit

Permalink
Adjust Handle.get() behavior - throw exception if attempting to get()…
Browse files Browse the repository at this point in the history
… reference which was destroyed.
  • Loading branch information
manovotn committed Nov 1, 2021
1 parent e53493f commit 7ec75c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/src/main/java/jakarta/enterprise/inject/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ interface Handle<T> extends AutoCloseable {
* @return the contextual reference
* @see Instance#get()
* @throws IllegalStateException If the producing {@link Instance} does not exist
* @throws IllegalStateException If invoked on {@link Handle} that previously successfully destroyed its
* underlying contextual reference
*/
T get();

Expand Down
3 changes: 2 additions & 1 deletion spec/src/main/asciidoc/core/injectionandresolution.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ public interface Handle<T> extends AutoCloseable {
}
----

The `get()` method returns a contextual reference object. The contextual reference is resolved lazily.
The `get()` method returns a contextual reference object. The contextual reference is resolved lazily. Throws
`IllegalStateException` if invoked on `Handle` that previously successfully destroyed its underlying contextual reference.

The `getBean()` method returns the `Bean` object representing metadata of the given contextual instance.

Expand Down

0 comments on commit 7ec75c2

Please sign in to comment.