Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java LS should lock its workspace #1010

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import java.io.File;

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;

public class LanguageServer implements IApplication {

Expand All @@ -22,6 +26,15 @@ public class LanguageServer implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {

Location instanceLoc = Platform.getInstanceLocation();
if (!instanceLoc.lock()) {
File workspaceFile = new File(instanceLoc.getURL().getFile());
if (workspaceFile.exists()) {
JavaLanguageServerPlugin.logError("Could not launch the server because associated workspace is currently in use by another Java LS server.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at that point there's no connection established so no message can surface to the client

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can only use the standard Eclipse log (/.metadata/.log)

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if workspaceFile doesn't exist we don't log anything???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try add the following property:

java.jdt.ls.vmargs": "-Djdt.ls.debug=true...",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my point is you have a workflow branch where the server would exit without logging anything whatsoever. Makes it harder to troubleshoot

return Integer.valueOf(1);
}

JavaLanguageServerPlugin.startLanguageServer(this);
synchronized(waitLock){
while (!shutdown) {
Expand Down