From 2a631cb6d7547b7c9497762065a6e9bce165b573 Mon Sep 17 00:00:00 2001 From: Jiaming <71547730+Jiaaming@users.noreply.github.com> Date: Thu, 1 Aug 2024 17:34:56 +0800 Subject: [PATCH] Fix: add bsp dispose method (#1543) --- extension/src/bs/BspProxy.ts | 6 ++++++ extension/src/bs/BuildServerConnector.ts | 6 ++++++ extension/src/bs/JdtlsImporterConnector.ts | 6 ++++++ extension/src/server/GradleServer.ts | 2 ++ 4 files changed, 20 insertions(+) diff --git a/extension/src/bs/BspProxy.ts b/extension/src/bs/BspProxy.ts index 9097c3a1c..cdf90b3e1 100644 --- a/extension/src/bs/BspProxy.ts +++ b/extension/src/bs/BspProxy.ts @@ -86,4 +86,10 @@ export class BspProxy { // TODO: Implement more specific error handling logic here }); } + + public closeConnection(): void { + this.buildServerConnector.close(); + this.jdtlsImporterConnector.close(); + this.logger.info("Build Server connection closed"); + } } diff --git a/extension/src/bs/BuildServerConnector.ts b/extension/src/bs/BuildServerConnector.ts index 6ee4da153..0ff1953c5 100644 --- a/extension/src/bs/BuildServerConnector.ts +++ b/extension/src/bs/BuildServerConnector.ts @@ -34,4 +34,10 @@ export class BuildServerConnector { public getServerPipePath(): string { return this.serverPipePath; } + + public close(): void { + this.serverConnection?.end(); + this.serverConnection?.dispose(); + this.serverPipeServer.close(); + } } diff --git a/extension/src/bs/JdtlsImporterConnector.ts b/extension/src/bs/JdtlsImporterConnector.ts index 29b6f2fa4..de03e6b95 100644 --- a/extension/src/bs/JdtlsImporterConnector.ts +++ b/extension/src/bs/JdtlsImporterConnector.ts @@ -68,4 +68,10 @@ export class JdtlsImporterConnector { public getImporterConnection(): rpc.MessageConnection | null { return this.importerConnection; } + + public close(): void { + this.importerConnection?.end(); + this.importerConnection?.dispose(); + this.importerPipeServer.close(); + } } diff --git a/extension/src/server/GradleServer.ts b/extension/src/server/GradleServer.ts index bcff565b4..4d214ae88 100644 --- a/extension/src/server/GradleServer.ts +++ b/extension/src/server/GradleServer.ts @@ -88,6 +88,7 @@ export class GradleServer { this._onDidStop.fire(null); this.ready = false; this.process?.removeAllListeners(); + this.bspProxy.closeConnection(); if (this.restarting) { this.restarting = false; await this.start(); @@ -163,6 +164,7 @@ export class GradleServer { } public async asyncDispose(): Promise { + this.bspProxy.closeConnection(); this.process?.removeAllListeners(); await this.killProcess(); this.ready = false;