diff --git a/vscode-extensions/vscode-spring-boot/lib/debug-config-provider.ts b/vscode-extensions/vscode-spring-boot/lib/debug-config-provider.ts index 805bb580f9..0afae89312 100644 --- a/vscode-extensions/vscode-spring-boot/lib/debug-config-provider.ts +++ b/vscode-extensions/vscode-spring-boot/lib/debug-config-provider.ts @@ -77,11 +77,13 @@ export function startDebugSupport(): Disposable { async function handleCustomDebugEvent(e: VSCode.DebugSessionCustomEvent): Promise { if (e.session?.type === 'java' && e?.body?.type === 'processid') { const debugConfiguration: DebugConfiguration = e.session.configuration; - setTimeout(async () => { - const pid = await getAppPid(e.body as ProcessEvent); - const processKey = pid.toString(); - VSCode.commands.executeCommand('sts/livedata/connect', { processKey }); - }, 500); + if (canConnect(debugConfiguration)) { + setTimeout(async () => { + const pid = await getAppPid(e.body as ProcessEvent); + const processKey = pid.toString(); + VSCode.commands.executeCommand('sts/livedata/connect', { processKey }); + }, 500); + } } } @@ -114,3 +116,12 @@ function isActuatorJarFile(f: string): boolean { } return false; } + +function canConnect(debugConfiguration: DebugConfiguration): boolean { + if (isActuatorOnClasspath(debugConfiguration)) { + return debugConfiguration.vmArgs + && debugConfiguration.vmArgs.indexOf(`${JMX_VM_ARG}true`) >= 0 + && debugConfiguration.vmArgs.indexOf(`${ADMIN_VM_ARG}true`) >= 0 + } + return false; +}