Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/java/com/basho/riak/client/api/RiakClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.lang.AutoCloseable;

/**
* <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
Expand Down Expand Up @@ -158,7 +159,7 @@
* @author Sergey Galkin <srggal at gmail dot com>
* @since 2.0
*/
public class RiakClient
public class RiakClient implements AutoCloseable
{
private final RiakCluster cluster;

Expand Down Expand Up @@ -416,6 +417,18 @@ public Future<Boolean> shutdown()
return cluster.shutdown();
}


/**
* Implementation of the AutoCloseable-Inteface.
* <p>
* The Client will be automatically shut down when used with try-with-resource statement
* </p>
*/
@Override
public void close() throws ExecutionException, InterruptedException {
this.shutdown().get();
}

/**
* Get the RiakCluster being used by this client.
* <p>
Expand Down