Skip to content

Commit

Permalink
Fix connection leak (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
finefuture authored Jan 10, 2024
1 parent e2e7add commit ab1e63e
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ public ReportServiceContractResponse reportServiceContract(ReportServiceContract
ResponseProto.Response reportServiceContractResponse =
stub.reportServiceContract(buildReportServiceContractRequest(req));
GrpcUtil.checkResponse(reportServiceContractResponse);
ReportServiceContractResponse resp = new ReportServiceContractResponse();
return resp;
return new ReportServiceContractResponse();
} catch (Throwable t) {
if (t instanceof PolarisException) {
throw t;
Expand Down Expand Up @@ -723,6 +722,7 @@ public void doDestroy() {
LOG.info("start to destroy connector {}", getName());
ThreadPoolUtils.waitAndStopThreadPools(
new ExecutorService[]{sendDiscoverExecutor, buildInExecutor, updateServiceExecutor});
destroyStreamClient();
if (null != connectionManager) {
connectionManager.destroy();
}
Expand Down Expand Up @@ -759,5 +759,13 @@ public void run() {
}
}


private void destroyStreamClient() {
for (AtomicReference<SpecStreamClient> streamClientRef : streamClients.values()) {
SpecStreamClient streamClient = streamClientRef.get();
if (null == streamClient) {
continue;
}
streamClient.closeStream(true);
}
}
}

0 comments on commit ab1e63e

Please sign in to comment.