Skip to content

Commit 06eacf5

Browse files
author
Sylvain Lebresne
committed
Add methods to check if a cluster/session instance if closed
JAVA-114 #fixes
1 parent 4417ca0 commit 06eacf5

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

driver-core/CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
1.0.7:
5+
------
6+
7+
- [new] Add method to check if a Cluster/Session instance has been closed already (JAVA-114)
8+
49
1.0.6:
510
------
611

driver-core/src/main/java/com/datastax/driver/core/Cluster.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ public boolean shutdown(long timeout, TimeUnit unit) {
305305
}
306306
}
307307

308+
/**
309+
* Whether shutdown has been called on this Cluster instance.
310+
*
311+
* @return {@code true} if {@code shutdown} has been called on this instance,
312+
* {@code false} otherwise.
313+
*/
314+
public boolean isShutdown() {
315+
return manager.isShutdown.get();
316+
}
317+
308318
/**
309319
* Initializer for {@link Cluster} instances.
310320
* <p>

driver-core/src/main/java/com/datastax/driver/core/Session.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ public interface Session {
228228
*/
229229
public boolean shutdown(long timeout, TimeUnit unit);
230230

231+
/**
232+
* Whether shutdown has been called on this Session instance.
233+
*
234+
* @return {@code true} if this instance is shut down, {@code false} otherwise.
235+
*/
236+
public boolean isShutdown();
237+
231238
/**
232239
* Returns the {@code Cluster} object this session is part of.
233240
*

driver-core/src/main/java/com/datastax/driver/core/SessionManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public boolean shutdown(long timeout, TimeUnit unit) {
155155
}
156156
}
157157

158+
public boolean isShutdown() {
159+
return isShutdown.get();
160+
}
161+
158162
public Cluster getCluster() {
159163
return cluster;
160164
}

0 commit comments

Comments
 (0)