Skip to content

Commit

Permalink
[vscode] Do not attempt to auto-connect if actuators not on classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
BoykoAlex committed May 31, 2022
1 parent 750a13f commit 24117a4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions vscode-extensions/vscode-spring-boot/lib/debug-config-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export function startDebugSupport(): Disposable {
async function handleCustomDebugEvent(e: VSCode.DebugSessionCustomEvent): Promise<void> {
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);
}
}
}

Expand Down Expand Up @@ -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;
}

0 comments on commit 24117a4

Please sign in to comment.