diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 06b7bb057..71d31db9b 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -282,7 +282,7 @@ public abstract class Mode { public void rebuildLibraryList() { //new Exception("Rebuilding library list").printStackTrace(System.out); // reset the table mapping imports to libraries - importToLibraryTable = new HashMap>(); + HashMap> importToLibraryTable = new HashMap<>(); Library core = getCoreLibrary(); if (core != null) { @@ -323,6 +323,11 @@ public abstract class Mode { for (Library lib : contribLibraries) { lib.addPackageList(importToLibraryTable); } + + // Make this Map thread-safe + this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable); + + base.getEditors().forEach(Editor::librariesChanged); } diff --git a/java/src/processing/mode/java/pdex/ErrorCheckerService.java b/java/src/processing/mode/java/pdex/ErrorCheckerService.java index ec5d2d4c3..6fa7c6b30 100644 --- a/java/src/processing/mode/java/pdex/ErrorCheckerService.java +++ b/java/src/processing/mode/java/pdex/ErrorCheckerService.java @@ -703,7 +703,7 @@ public class ErrorCheckerService { .filter(pckg -> !ignorableImport(pckg)) .map(pckg -> { try { - return mode.getLibrary(pckg); // TODO: this may not be thread-safe + return mode.getLibrary(pckg); } catch (SketchException e) { return null; }