diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/CompilationUnitCache.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/CompilationUnitCache.java index 8165daffb..cca84c58e 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/CompilationUnitCache.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/CompilationUnitCache.java @@ -97,7 +97,13 @@ public final class CompilationUnitCache implements DocumentContentProvider { .build(); this.projectToDocs = CacheBuilder.newBuilder().build(); - this.lookupEnvCache = CacheBuilder.newBuilder().build(); + this.lookupEnvCache = CacheBuilder.newBuilder().removalListener(new RemovalListener, INameEnvironmentWithProgress>>() { + @Override + public void onRemoval(RemovalNotification, INameEnvironmentWithProgress>> notification) { + notification.getValue().getT2().cleanup(); + } + + }).build(); this.documentService = server == null ? null : server.getTextDocumentService();