Skip to content
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

Fix ConcurrentModificationException in the cache, fixes #405 #406

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,28 @@ public void validateRecords() {
final Path path = dir.resolve((Path) event.context());
LOG.debug("Got watcher event {} for file {}", kind.name(), path);
final List<CacheRecord> records = recordsByPath.remove(path);
LOG.debug("Records for path {}: {}", path, records);
if (records != null) {
LOG.debug("Invalidating records of path {}", path);
remove(records);
synchronized (records) {
LOG.debug("Invalidating records for path {}: {}", path, records);
remove(records);
}
}
} else if (kind == StandardWatchEventKinds.OVERFLOW) {
/* Invalidate all records under the given dir */
LOG.debug("Got overflow event for path {}", dir);
Iterator<Map.Entry<Path, List<CacheRecord>>> it = recordsByPath.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Path, List<CacheRecord>> en = it.next();
if (en.getKey().getParent().equals(dir)) {
final Path path = en.getKey();
if (path.getParent().equals(dir)) {
it.remove();
LOG.debug("Invalidating records of path {}", en.getKey());
remove(en.getValue());
final List<CacheRecord> records = en.getValue();
if (records != null) {
synchronized (records) {
LOG.debug("Invalidating records of path {}: {}", path, records);
remove(records);
}
}
}
}
}
Expand Down