Skip to content

Commit 294ffef

Browse files
fbricondatho7561
authored andcommitted
fix: safeguard workspace hash computation in telemetry service
Signed-off-by: Fred Bricon <[email protected]>
1 parent 19e5b5a commit 294ffef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/telemetry.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,23 @@ export namespace Telemetry {
2525
if (!!telemetryManager) {
2626
throw new Error("The telemetry service for vscode-java has already been started");
2727
}
28-
workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|'));
28+
workspaceHash = computeWorkspaceHash();
2929
workspace.onDidChangeWorkspaceFolders(() => {
30-
workspaceHash = cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|'));
30+
workspaceHash = computeWorkspaceHash();
3131
});
3232
const redhatService = await getRedHatService(context);
3333
const telemService = await redhatService.getTelemetryService();
3434
telemetryManager = telemService;
3535
return telemService;
3636
}
3737

38+
function computeWorkspaceHash(): number {
39+
if (!workspace.workspaceFolders?.length) {
40+
return 0;
41+
}
42+
return cyrb53(workspace.workspaceFolders.map(f => f.uri.toString()).join('|'));
43+
}
44+
3845
/**
3946
* Send a telemetry event with the given name and data
4047
*

0 commit comments

Comments
 (0)