From d6899579fc03b598afc1550240e5e46e7f10409b Mon Sep 17 00:00:00 2001 From: Olivier Cailloux Date: Sun, 16 Dec 2018 17:09:50 +0100 Subject: [PATCH] Added close method, #108 --- api/src/main/java/javax/json/bind/Jsonb.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/javax/json/bind/Jsonb.java b/api/src/main/java/javax/json/bind/Jsonb.java index 536f5ff7..e1cbb8eb 100644 --- a/api/src/main/java/javax/json/bind/Jsonb.java +++ b/api/src/main/java/javax/json/bind/Jsonb.java @@ -95,12 +95,6 @@ * *

All the methods in this class are safe for use by multiple concurrent threads.

* - *

Calling {@code Closable.close()} method will cleanup all CDI managed components - * (such as adapters with CDI dependencies) created during interaction with Jsonb. - * Calling {@code close()} must be done after all threads has finished interaction with Jsonb. - * If there are remaining threads working with Jsonb and {@code close()} is called, behaviour is undefined. - *

- * * @see Jsonb * @see JsonbBuilder * @see java.util.ServiceLoader @@ -354,4 +348,17 @@ public interface Jsonb extends AutoCloseable { * @since JSON Binding 1.0 */ void toJson(Object object, Type runtimeType, OutputStream stream) throws JsonbException; + + /** + * Closes this resource, relinquishing any underlying resources. In particular, + * cleans up all CDI managed components (such as adapters with CDI dependencies) + * created during interaction with Jsonb. {@code close()} must be called after + * all threads have finished interaction with Jsonb. If there are remaining + * threads working with Jsonb after {@code close()} has been called, behaviour + * is undefined. + * + * @throws JsonbException If any unexpected problem occurs during the close. + */ + @Override + void close() throws JsonbException; }