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>
This commit is contained in:
ti-srebot 2021-10-28 16:39:16 +08:00 committed by GitHub
parent 9052bd1519
commit db2073d8eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -71,11 +71,14 @@ public class TiSession implements AutoCloseable {
private MetricsServer metricsServer;
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 = new ChannelFactory(conf.getMaxFrameSize());
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");
}