-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throws exception when closing editors #1179
Comments
another exception found in the log in the same area, but not related to the
|
Further analysis for the second case: This seems to happen sometime before:
which is followed by:
then:
It looks suspicious that those exceptions are being thrown (looks like the parser can't do its job), but then a |
Ok, I think I know what is going on here. The high level summary is:
Now, the parsing itself throws a bunch of exceptions internally (due to various reasons, but things like that could happen anytime, especially because parallel things could happen anytime, like a local maven build removing JARs from disc that belonged to the classpath, source files being deleted, whatever). There is no way to ensure that the parsing will succeed, so we need to deal with the failure situation. At the moment, the cache keeps the On an additional note, if the I think we need to do two things here:
There might still be the case where the user of the CompilationUnitCache gets a (cc. @BoykoAlex ) |
Perhaps completing the CU future exceptionally and then if it has completed exceptionally chain something to the future to invalidate the cache entry... private synchronized CompletableFuture<CompilationUnit> requestCU(IJavaProject project, URI uri) throws ExecutionException {
CompletableFuture<CompilationUnit> cuFuture = uriToCu.getIfPresent(uri);
if (cuFuture == null) {
cuFuture = CompletableFuture.supplyAsync(() -> {
try {
logger.info("Started parsing CU for " + uri);
Tuple2<List<Classpath>, INameEnvironmentWithProgress> lookupEnvTuple = loadLookupEnvTuple(project);
String utiStr = uri.toASCIIString();
String unitName = utiStr.substring(utiStr.lastIndexOf("/"));
CompilationUnit cUnit = parse2(fetchContent(uri).toCharArray(), utiStr, unitName, lookupEnvTuple.getT1(), lookupEnvTuple.getT2());
logger.debug("CU Cache: created new AST for {}", uri.toASCIIString());
logger.info("Parsed successfully CU for " + uri);
return cUnit;
} catch (Exception e) {
// Complete future exceptionally
throw new CompletionException(e);
}
}, createCuExecutorThreadPool);
// Cache the future
uriToCu.put(uri, cuFuture);
// If CU future completed exceptionally invalidate the cache entry
cuFuture.exceptionally(t -> {
logger.error("", t);
uriToCu.invalidate(uri);
return null;
});
}
return cuFuture;
} |
Here is the branch with a candidate fix: https://github.com/spring-projects/sts4/tree/cu-cache-fix |
Lets try the fix: 4ce4f02 - seems harmless and likely to help with the issue above |
Applied a Spring Boot upgrade, then quickly closed a bunch of open editors. Popup appears, showing an error for
textDocument/definition
:The text was updated successfully, but these errors were encountered: