Skip to content

Commit

Permalink
Do not crash on re-registration
Browse files Browse the repository at this point in the history
Some language servers such as OmniSharp may (erroneously but not
fatally) re-register the same capability multiple times.
Instead of crashing in such case, just log.
  • Loading branch information
mickaelistria committed Sep 17, 2024
1 parent fdc2066 commit 0dd453f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.IProgressMonitor;
Expand Down Expand Up @@ -1017,8 +1018,11 @@ void registerCapability(RegistrationParams params) {
private void addRegistration(Registration reg, Runnable unregistrationHandler) {
String regId = reg.getId();
synchronized (dynamicRegistrations) {
Assert.isLegal(!dynamicRegistrations.containsKey(regId), "Registration id is not unique"); //$NON-NLS-1$
dynamicRegistrations.put(regId, unregistrationHandler);
if (dynamicRegistrations.containsKey(regId)) {
ILog.get().warn("A registration with id " + regId + " already exists. Unregistering may not fully work in this case.\n"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
dynamicRegistrations.put(regId, unregistrationHandler);
}
}
}

Expand Down

0 comments on commit 0dd453f

Please sign in to comment.