Skip to content

Commit

Permalink
enable qodana caching between runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Sep 29, 2024
1 parent b643bfe commit af9d01e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ jobs:
with:
java: ${{ env.JAVA_VERSION }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: build -x test
arguments: check -x test
- name: Qodana - Code Inspection
uses: JetBrains/qodana-action@84494be4d1a2f64ec1c4bfdf475406e246e34672 # v2024.2.3
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
upload-result: true
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,7 @@ void performCleanUp(@Nullable Runnable task) {
* schedule an asynchronous maintenance task. This may occur due to a concurrent write after the
* maintenance work had started or if the amortized threshold of work per clean up was reached.
*/
@SuppressWarnings("resource")
void rescheduleCleanUpIfIncomplete() {
if (drainStatusOpaque() != REQUIRED) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
import com.google.common.collect.Maps;
import com.google.common.collect.Range;
import com.google.common.testing.GcFinalization;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.Uninterruptibles;

/**
Expand Down Expand Up @@ -1947,9 +1948,10 @@ public void put_spinToCompute(BoundedLocalCache<Int, Int> cache, CacheContext co
var node = cache.data.get(context.absentKey());
node.retire();

var future = new Future<?>[1];
var value = cache.data.compute(context.absentKey(), (k, n) -> {
var writer = new AtomicReference<Thread>();
ConcurrentTestHarness.execute(() -> {
future[0] = ConcurrentTestHarness.submit(() -> {
writer.set(Thread.currentThread());
var oldValue = cache.put(context.absentKey(), context.absentKey());
assertThat(oldValue).isAnyOf(context.absentValue(), null);
Expand All @@ -1963,8 +1965,9 @@ public void put_spinToCompute(BoundedLocalCache<Int, Int> cache, CacheContext co
});
assertThat(value).isNull();

await().untilAsserted(() ->
assertThat(cache).containsEntry(context.absentKey(), context.absentKey()));
await().untilAsserted(() -> assertThat(cache)
.containsEntry(context.absentKey(), context.absentKey()));
assertThat(Futures.getUnchecked(future[0])).isNull();
cache.afterWrite(cache.new RemovalTask(node));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ private void checkLinks(BoundedLocalCache<Object, Object> bounded,
Set<Node<Object, Object>> seen = Sets.newIdentityHashSet();
for (var cell : deques.cellSet()) {
long weightedSize = scanLinks(bounded, cell.getValue(), seen);
check(cell.getRowKey()).that(weightedSize).isEqualTo(cell.getColumnKey());
check("%s: %s in %s", cell.getRowKey(), cell.getValue(), bounded.data)
.that(weightedSize).isEqualTo(cell.getColumnKey());
totalSize += cell.getValue().size();
totalWeightedSize += weightedSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicReferenceArray;
Expand Down Expand Up @@ -58,6 +59,11 @@ public static void execute(Runnable task) {
executor.execute(task);
}

/** Submits the task using the shared thread pool and returns a future representing its result. */
public static Future<?> submit(Runnable task) {
return executor.submit(task);
}

/**
* Executes a task, on N threads, all starting at the same time.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bouncycastle-jdk18on = "1.78.1"
cache2k = "2.6.1.Final"
caffeine = "3.1.8"
checker-framework = "3.47.0"
checkstyle = "10.18.1"
checkstyle = "10.18.2"
coherence = "22.06.2"
commons-collections4 = "4.4"
commons-compress = "1.27.1"
Expand Down
4 changes: 3 additions & 1 deletion gradle/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,6 @@ fun setProjectEncoding() {
}
}

setProjectEncoding()
if (System.getenv("CI").isNullOrEmpty()) {
setProjectEncoding()
}
1 change: 1 addition & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "1.0"
projectJDK: "21"
linter: jetbrains/qodana-jvm-community:2024.2
profile:
name: qodana.recommended
licenseRules:
Expand Down

0 comments on commit af9d01e

Please sign in to comment.