Skip to content

Commit

Permalink
fix SmartRawKVClient close (tikv#393) (tikv#394)
Browse files Browse the repository at this point in the history
Signed-off-by: marsishandsome <[email protected]>
  • Loading branch information
ti-srebot authored Dec 11, 2021
1 parent 83fb5f4 commit 952627a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/tikv/common/TiSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ private synchronized void shutdown(boolean now) throws Exception {
if (metricsServer != null) {
metricsServer.close();
}

if (circuitBreaker != null) {
circuitBreaker.close();
}
}

if (now) {
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/tikv/raw/SmartRawKVClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public SmartRawKVClient(RawKVClientBase client, CircuitBreaker breaker) {
this.circuitBreaker = breaker;
}

@Override
public void close() throws Exception {
circuitBreaker.close();
client.close();
}

@Override
public void put(ByteString key, ByteString value) {
callWithCircuitBreaker("put", () -> client.put(key, value));
Expand Down Expand Up @@ -268,6 +262,11 @@ private void callWithCircuitBreaker(String funcName, Function0 func) {
});
}

@Override
public void close() throws Exception {
client.close();
}

public interface Function1<T> {
T apply();
}
Expand Down

0 comments on commit 952627a

Please sign in to comment.