-
Notifications
You must be signed in to change notification settings - Fork 409
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
||
|
@@ -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."); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if workspaceFile doesn't exist we don't log anything??? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can try add the following property:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)