redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.07k stars 433 forks source link

Reloading a window apprently clears Java project settings due to different workspace storage chosen #3671

Open nya3jp opened 3 months ago

nya3jp commented 3 months ago
Environment
Steps To Reproduce
  1. Open a large Java project on a remote machine with SSH remote development
  2. Configure the Java project, e.g. add some source paths
  3. Reload the window
Current Result

Configuration added in the step 2 is apparently lost.

Expected Result

Configuration added in the step 2 is kept.

Additional Informations

I found that the -data directory passed to jdt.ls differs before/after the reload.

Notice the -1 suffix added to the workspace storage directory.

In fact, a VSCode extension may receive different context.storageUri for the identical workspace when multiple instances of VSCode opens the workspace concurrently (c.f. https://github.com/microsoft/vscode/issues/128234). This can happen even on a window reload because a storage directory lock is released only on the VSCode process exit (https://github.com/microsoft/vscode/blob/5f646b8e67a869ef33061085ffe0e377d5ba040c/src/vs/workbench/api/node/extHostStoragePaths.ts#L52).

I guess this problem happens only in remote development because VSCode skips obtaining locks for local extension hosts (https://github.com/microsoft/vscode/issues/128528).