fix unclosed Thread when create TiSession error (#300)

Signed-off-by: marsishandsome <marsishandsome@gmail.com>
This commit is contained in:
Liangliang Gu 2021-10-28 16:28:27 +08:00 committed by GitHub
parent f9cb05784d
commit 489e5c22ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -77,6 +77,10 @@ public class TiSession implements AutoCloseable {
private static final int MAX_SPLIT_REGION_STACK_DEPTH = 6;
public TiSession(TiConfiguration conf) {
// may throw org.tikv.common.MetricsServer - http server not up
// put it at the beginning of this function to avoid unclosed Thread
this.metricsServer = MetricsServer.getInstance(conf);
this.conf = conf;
this.channelFactory =
conf.isTlsEnable()
@ -92,7 +96,6 @@ public class TiSession implements AutoCloseable {
this.client = PDClient.createRaw(conf, channelFactory);
this.enableGrpcForward = conf.getEnableGrpcForward();
this.metricsServer = MetricsServer.getInstance(conf);
if (this.enableGrpcForward) {
logger.info("enable grpc forward for high available");
}