Skip to content

Commit 3ccf4b9

Browse files
committed
FaunaClient no longer needs to be closed
1 parent a1fa2c5 commit 3ccf4b9

File tree

6 files changed

+11
-31
lines changed

6 files changed

+11
-31
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public class Main {
8686
Obj("name", Value("my-first-database"))
8787
)
8888
).get();
89-
90-
adminClient.close();
9189
}
9290
}
9391
```
@@ -188,8 +186,6 @@ object Main extends App {
188186
)
189187

190188
Await.result(result, Duration.Inf)
191-
192-
client.close()
193189
}
194190
```
195191

docs/SpellExample.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,14 @@ public static void main(String[] args) throws Exception {
6161

6262
String key = keyResults.at("secret").to(String.class).get();
6363

64-
//Create the client query in a try-with-resources to ensure it gets closed
65-
//Because a Fauna Client implements AutoCloseable it will be closed when the try block finishes
66-
try (FaunaClient client = adminClient.newSessionClient(key)) {
67-
System.out.println("Connected to Fauna database " + DB_NAME + " with server role\n");
68-
runSpellExamples(DB_NAME, client);
69-
}
64+
FaunaClient client = adminClient.newSessionClient(key)
65+
System.out.println("Connected to Fauna database " + DB_NAME + " with server role\n");
66+
runSpellExamples(DB_NAME, client);
7067

7168
/*
72-
* Delete the database and close the admin connection
69+
* Delete the database
7370
*/
7471
deleteDB(adminClient, DB_NAME);
75-
adminClient.close();
7672
System.out.println("Disconnected from FaunaDB as Admin!");
7773
}
7874

docs/SpellExample.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,13 @@ object SpellExample {
6161
val key: String = keyResults("secret").to[String].get
6262
val client = adminClient.sessionClient(key)
6363

64-
try
65-
{
66-
println(s"Connected to Fauna database $DB_NAME with server role\n")
67-
runSpellExamples(DB_NAME, client)
68-
}
69-
finally {
70-
client.close()
71-
}
64+
println(s"Connected to Fauna database $DB_NAME with server role\n")
65+
runSpellExamples(DB_NAME, client)
7266

7367
/*
74-
* Just to keep things neat and tidy, delete the database and close the client connection
68+
* Just to keep things neat and tidy, delete the database
7569
*/
7670
deleteDB(adminClient, DB_NAME)
77-
adminClient.close()
7871
println("Disconnected from FaunaDB as Admin!")
7972
}
8073

faunadb-common/src/main/java/com/faunadb/common/Connection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ private Connection(URL faunaRoot, String authToken, HttpClient client, MetricReg
231231

232232
/**
233233
* Creates a new {@link Connection} sharing its underneath I/O resources. Queries submitted to a
234-
* session connection will be authenticated with the token provided. Close the parent Connection
235-
* for freeing up any resources held by the parent connection and this session connection.
234+
* session connection will be authenticated with the token provided.
236235
*
237236
* @param authToken the token or key to be used to authenticate requests to the new {@link Connection}
238237
* @return a new {@link Connection}

faunadb-java/src/main/java/com/faunadb/client/FaunaClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ private FaunaClient(Connection connection) {
160160

161161
/**
162162
* Creates a session client with the user secret provided. Queries submitted to a session client will be
163-
* authenticated with the secret provided. A session client shares its parent's {@link Connection} instance
164-
* and thus it does not need be closed after its usage. Close the parent session for freeing up any
165-
* resources held by the parent session and this session client.
163+
* authenticated with the secret provided. A session client shares its parent's {@link Connection} instance.
166164
*
167165
* @param secret user secret for the session client
168166
* @return a new {@link FaunaClient}

faunadb-scala/src/main/scala/faunadb/FaunaClient.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ class FaunaClient private (connection: Connection) {
254254
/**
255255
* Creates a new scope to execute session queries. Queries submitted within the session scope will be
256256
* authenticated with the secret provided. A session client shares its parent's [[com.faunadb.common.Connection]]
257-
* instance and thus it does not need to be closed after its usage. Close the parent session for freeing up any
258-
* resources held by the parent session and this session client.
257+
* instance.
259258
*
260259
* @param secret user secret for the session scope
261260
* @param session a function that receives a session client
@@ -268,8 +267,7 @@ class FaunaClient private (connection: Connection) {
268267

269268
/**
270269
* Create a new session client. The returned session client shares its parent [[com.faunadb.common.Connection]]
271-
* instance and thus it does not need to be closed after its usage. Close the parent session for freeing up any
272-
* resources held by the parent session and this session client.
270+
* instance.
273271
*
274272
* @param secret user secret for the session client
275273
* @return a new session client

0 commit comments

Comments
 (0)