Skip to content

Commit

Permalink
Dispose snapshot synchronized to prevent from some problem caused by …
Browse files Browse the repository at this point in the history
…data inconsistency.
  • Loading branch information
xupengfei11 committed Nov 27, 2023
1 parent dbf5e4b commit ae6f090
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -331,11 +331,11 @@ public Progress progressOfAnalysis(@ApiParameterMeta(targetPath = true) Path tar
}

public void release(@ApiParameterMeta(targetPath = true) Path target) {
cachedAnalyzer.invalidate(target);
cleanAndDisposeAnalyzerCache(target);
}

public void clean(@ApiParameterMeta(targetPath = true) Path target) {
cachedAnalyzer.invalidate(target);
cleanAndDisposeAnalyzerCache(target);
File errorLog = errorLogFile(target);
if (errorLog.exists()) {
if (!errorLog.delete()) {
@@ -355,4 +355,13 @@ protected File errorLogFile(Path path) {
protected final boolean isActive(Path target) {
return cachedAnalyzer.getIfPresent(target) != null || buildingAnalyzer.containsKey(target);
}

private void cleanAndDisposeAnalyzerCache(Path target) {
// Dispose snapshot synchronized to prevent from some problem caused by data inconsistency.
Analyzer analyzer = cachedAnalyzer.getIfPresent(target);
cachedAnalyzer.invalidate(target);
if (analyzer != null) {
cachedAnalyzerRemoved(analyzer);
}
}
}

0 comments on commit ae6f090

Please sign in to comment.