Skip to content

Commit db2073d

Browse files
fix unclosed Thread when create TiSession error (#300) #301
Signed-off-by: ti-srebot <ti-srebot@pingcap.com> Co-authored-by: Liangliang Gu <marsishandsome@gmail.com>
1 parent 9052bd1 commit db2073d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/tikv/common/TiSession.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ public class TiSession implements AutoCloseable {
7171
private MetricsServer metricsServer;
7272

7373
public TiSession(TiConfiguration conf) {
74+
// may throw org.tikv.common.MetricsServer - http server not up
75+
// put it at the beginning of this function to avoid unclosed Thread
76+
this.metricsServer = MetricsServer.getInstance(conf);
77+
7478
this.conf = conf;
7579
this.channelFactory = new ChannelFactory(conf.getMaxFrameSize());
7680
this.client = PDClient.createRaw(conf, channelFactory);
7781
this.enableGrpcForward = conf.getEnableGrpcForward();
78-
this.metricsServer = MetricsServer.getInstance(conf);
7982
if (this.enableGrpcForward) {
8083
logger.info("enable grpc forward for high available");
8184
}

0 commit comments

Comments
 (0)