Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-urruty-sonarsource committed Dec 7, 2023
1 parent cbd4a04 commit ebc2e6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ public synchronized boolean contains(String key) {
return store.contains(key);
}

public synchronized void save(String key, Collection<T> findings) throws IOException {
FileUtils.mkdirs(storeBasePath);
store.write(key, transform(findings));
public void save(String key, Collection<T> findings) throws IOException {
var findingsToWrite = transform(findings);
synchronized (this) {
FileUtils.mkdirs(storeBasePath);
store.write(key, findingsToWrite);
}
}

public synchronized void clear(String key) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void clear() {
}

public boolean contains(VirtualFile virtualFile) {
return getLive(virtualFile) != null;
return cache.containsKey(virtualFile);
}

private String createKey(VirtualFile virtualFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void should_save_and_read_cache_only() throws IOException {
}

@Test
void should_flush_if_full() throws IOException {
void should_flush_if_full() {
var issue1 = createTestIssue("r1");
var file0 = myFixture.copyFileToProject("foo.php", "foo0.php");
cache.replaceFindings(Map.of(file0, List.of(issue1)));
Expand Down Expand Up @@ -168,7 +168,6 @@ void testConcurrentAccess() throws Exception {
for (Future<?> task : tasks) {
task.get(1, TimeUnit.MINUTES);
}

}

private LiveIssue createTestIssue(String ruleKey) {
Expand Down

0 comments on commit ebc2e6a

Please sign in to comment.