You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by vi...@apache.org on 2022/02/20 12:37:24 UTC

[netbeans] branch master updated: LSPBindings synchronization fix

This is an automated email from the ASF dual-hosted git repository.

vieiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e5d7cc  LSPBindings synchronization fix
     new 646f84c  Merge pull request #3644 from vieiro/hotfix/lsp-client-sync
8e5d7cc is described below

commit 8e5d7cc170a056b6759952b893ca994459b3c0ae
Author: Antonio Vieiro <an...@vieiro.net>
AuthorDate: Sat Feb 19 21:46:33 2022 +0100

    LSPBindings synchronization fix
---
 .../netbeans/modules/lsp/client/LSPBindings.java   | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java
index 2fcb1cd..b2e7e06 100644
--- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java
+++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java
@@ -51,7 +51,6 @@ import java.util.logging.Logger;
 import java.util.stream.Collectors;
 import javax.swing.event.ChangeListener;
 import org.eclipse.lsp4j.ClientCapabilities;
-import org.eclipse.lsp4j.CompletionCapabilities;
 import org.eclipse.lsp4j.DocumentSymbolCapabilities;
 import org.eclipse.lsp4j.InitializeParams;
 import org.eclipse.lsp4j.InitializeResult;
@@ -346,9 +345,11 @@ public class LSPBindings {
 
                 lc.setBindings(bindings);
 
-                workspace2Extension2Server.put(root, 
-                    Arrays.stream(extensions)
-                    .collect(Collectors.toMap(k -> k, v -> bindings)));
+                synchronized(LSPBindings.class) {
+                    workspace2Extension2Server.put(root, 
+                        Arrays.stream(extensions)
+                        .collect(Collectors.toMap(k -> k, v -> bindings)));
+                }
                 WORKER.post(() -> cs.fireChange());
             } catch (InterruptedException | ExecutionException | IOException ex) {
                 Exceptions.printStackTrace(ex);
@@ -506,18 +507,20 @@ public class LSPBindings {
         @Override
         @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
         public void run() {
-            for (Map<String, ServerDescription> mime2Bindings : project2MimeType2Server.values()) {
-                for (ServerDescription description : mime2Bindings.values()) {
-                    LSPBindings b = description.bindings != null ? description.bindings.get() : null;
-                    if (b != null && b.process != null) {
-                        b.process.destroy();
+            synchronized(LSPBindings.class) {
+                for (Map<String, ServerDescription> mime2Bindings : project2MimeType2Server.values()) {
+                    for (ServerDescription description : mime2Bindings.values()) {
+                        LSPBindings b = description.bindings != null ? description.bindings.get() : null;
+                        if (b != null && b.process != null) {
+                            b.process.destroy();
+                        }
                     }
                 }
-            }
-            for (Map<String, LSPBindings> mime2Bindings : workspace2Extension2Server.values()) {
-                for (LSPBindings b : mime2Bindings.values()) {
-                    if (b != null && b.process != null) {
-                        b.process.destroy();
+                for (Map<String, LSPBindings> mime2Bindings : workspace2Extension2Server.values()) {
+                    for (LSPBindings b : mime2Bindings.values()) {
+                        if (b != null && b.process != null) {
+                            b.process.destroy();
+                        }
                     }
                 }
             }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists