Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/upgrade/display/notificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class NotificationManager implements IUpgradeIssuesRenderer {
sendInfo(operationId, {
operationName: "java.dependency.upgradeNotification.show",
extensionState,
source: hasCVEIssue ? Upgrade.SOURCE_CVE : Upgrade.SOURCE_JAVA_UPGRADE,
});

const buttons = hasCVEIssue
Expand Down
42 changes: 32 additions & 10 deletions src/upgrade/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export async function checkOrInstallAppModExtensionForUpgrade(
}

await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
sendInfo(operationId, {
operationName: "java.dependency.upgradeFlow.result",
upgradeFlowStep: "installSucceeded",
installType: state === "outdated" ? "updated" : "installed",
});
Comment thread
frankliu20 marked this conversation as resolved.

if (state === "outdated") {
// Extension was updated (not freshly installed) — reload required
Expand All @@ -219,18 +224,35 @@ export async function checkOrInstallAppModExtensionForUpgrade(
return false;
}

await checkOrPromptToEnableAppModExtension("upgrade");
// Wait until the freshly installed extension is registered, returning as
// soon as it is ready, or after a 5s timeout fallback at the latest.
await waitForExtensionReady(extensionIdToCheck, 5000);

// Wait briefly for the newly installed extension to activate
await new Promise(resolve => setTimeout(resolve, 2000));

// Re-check if the newly installed extension is active and meets version requirement
const newState = getExtensionState(extensionIdToCheck);
const canProceed = newState === "up-to-date";
sendInfo(operationId, {
operationName: "java.dependency.upgradeFlow.result",
upgradeFlowResult: canProceed ? "proceeded" : "activation-timeout",
upgradeFlowResult: "proceeded",
});
return canProceed;
return true;
Comment thread
frankliu20 marked this conversation as resolved.
})();
}
}

function waitForExtensionReady(extensionId: string, timeoutMs: number): Promise<void> {
return new Promise<void>(resolve => {
if (extensions.getExtension(extensionId)) {
resolve();
return;
}
let timer: NodeJS.Timeout;
const disposable = extensions.onDidChange(() => {
if (extensions.getExtension(extensionId)) {
clearTimeout(timer);
disposable.dispose();
resolve();
}
});
timer = setTimeout(() => {
disposable.dispose();
resolve();
}, timeoutMs);
});
}
Loading