sid-srini commented on code in PR #7610:
URL: https://github.com/apache/netbeans/pull/7610#discussion_r1702855021
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/singlesourcefile/SingleFileOptionsQueryImpl.java:
##########
@@ -60,13 +61,36 @@ public Result optionsFor(FileObject file) {
workspaces = workspace2Settings.keySet();
}
- for (Workspace w : workspaces) {
- FileObject folder = findWorkspaceFolder(w, file);
- if (folder != null) {
- return getResult(w, folder);
+ int count = 0;
+ try {
+ for (Workspace w : workspaces) {
+ if (w == null)
+ continue; // Since a WeakHashMap is in use, it
is possible to receive a null value.
+ FileObject folder = findWorkspaceFolder(w, file);
+ if (folder != null) {
+ return getResult(w, folder);
+ }
+ if (count++ == 0 && workspace == null)
+ workspace = w;
}
+ } catch (ConcurrentModificationException ignore) {
+ // In the rare event that a concurrent invocation of this
method caused the Map to change,
+ // at least avoid an unexpected exception for the invoker.
}
Review Comment:
Thank you @mbien. I've incorporated your suggestion and pushed the commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists