Skip to content

Commit 7b795b5

Browse files
committed
GH-1535: avoid concurrent modification exception by synchronizing access to the list of symbols for a specific project
Fixes GH-1535
1 parent 8cf3836 commit 7b795b5

File tree

1 file changed

+16
-14
lines changed
  • headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app

1 file changed

+16
-14
lines changed

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/app/SpringSymbolIndex.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -605,23 +605,25 @@ private Map<IJavaProject, Set<String>> getDocsPerProjectFromPaths(String[] paths
605605

606606
private Collection<? extends String> getDocsFromPath(IJavaProject project, String path) {
607607
List<WorkspaceSymbol> allProjectSymbols = this.symbolsByProject.get(project.getElementName());
608-
609608
Set<String> result = new HashSet<>();
610609

611610
if (allProjectSymbols != null) {
612-
for (WorkspaceSymbol symbol : allProjectSymbols) {
613-
Either<Location, WorkspaceSymbolLocation> location = symbol.getLocation();
614-
615-
String docURI = null;
616-
if (location.isLeft()) {
617-
docURI = location.getLeft().getUri();
618-
}
619-
else if (location.isRight()) {
620-
docURI = location.getRight().getUri();
621-
}
622-
623-
if (docURI != null && docURI.startsWith(path)) {
624-
result.add(docURI);
611+
612+
synchronized(allProjectSymbols) {
613+
for (WorkspaceSymbol symbol : allProjectSymbols) {
614+
Either<Location, WorkspaceSymbolLocation> location = symbol.getLocation();
615+
616+
String docURI = null;
617+
if (location.isLeft()) {
618+
docURI = location.getLeft().getUri();
619+
}
620+
else if (location.isRight()) {
621+
docURI = location.getRight().getUri();
622+
}
623+
624+
if (docURI != null && docURI.startsWith(path)) {
625+
result.add(docURI);
626+
}
625627
}
626628
}
627629
}

0 commit comments

Comments
 (0)