diff --git a/.github/actions/run-gradle/action.yml b/.github/actions/run-gradle/action.yml index d6ba991d77..3312a28a45 100644 --- a/.github/actions/run-gradle/action.yml +++ b/.github/actions/run-gradle/action.yml @@ -53,7 +53,7 @@ runs: website: jdk.java.net version: latest - name: Set up GraalVM - uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1 + uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1 if: inputs.java == 'GraalVM' with: distribution: 'graalvm' @@ -73,7 +73,7 @@ runs: distribution: temurin - name: Setup Gradle id: setup-gradle - uses: gradle/actions/setup-gradle@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0 + uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 env: JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }} ORG_GRADLE_PROJECT_org.gradle.java.installations.auto-download: 'false' diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml index 98a887f426..045966ac5d 100644 --- a/.github/workflows/actionlint.yml +++ b/.github/workflows/actionlint.yml @@ -14,9 +14,9 @@ jobs: allowed-endpoints: > api.github.com:443 github.com:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: actionlint - uses: reviewdog/action-actionlint@c6ee1eb0a5d47b2af53a203652b5dac0b6c4016e # v1.43.0 + uses: reviewdog/action-actionlint@9d8b58041eed1373f173e91b9a3db5a844197236 # v1.44.0 env: SHELLCHECK_OPTS: -e SC2001 -e SC2035 -e SC2046 -e SC2061 -e SC2086 -e SC2156 with: diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 4b9a3fb62d..9723c21b8c 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -31,7 +31,7 @@ jobs: disable-sudo: true egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Forbidden Apis uses: ./.github/actions/run-gradle with: @@ -49,7 +49,7 @@ jobs: disable-sudo: true egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Pmd uses: ./.github/actions/run-gradle with: @@ -67,7 +67,7 @@ jobs: disable-sudo: true egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Spotbugs uses: ./.github/actions/run-gradle with: diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index f1e881bbcb..c914da5821 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -39,7 +39,7 @@ jobs: raw.githubusercontent.com:443 services.gradle.org:443 www.graalvm.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Compute JMH Benchmark uses: ./.github/actions/run-gradle with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc731faae7..eb99f4625f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Prepare GraalVM if: env.JAVA_VERSION == 'GraalVM' shell: bash @@ -176,7 +176,7 @@ jobs: egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run tests (${{ env.JAVA_VERSION }}) uses: ./.github/actions/run-gradle with: @@ -195,7 +195,7 @@ jobs: find . -path */jacoco/*.exec -o -path */results/*.xml | tar czf ${{ env.ARTIFACT_NAME }}.tar.gz --files-from - - name: Upload test results - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 if: always() && (env.JAVA_VERSION == env.PUBLISH_JDK) with: retention-days: 1 @@ -231,11 +231,11 @@ jobs: storage.googleapis.com:443 uploader.codecov.io:443 - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - name: Download Tests Results - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 - name: Decompress run: find . -type f -name '*.tar.gz' -exec sh -c 'tar -zxf {} --one-top-level' \; - name: Combine Jacoco Reports @@ -287,7 +287,7 @@ jobs: ${{ env.ALLOWED_ENDPOINTS }} badgen.net:443 - name: Download Tests - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 - name: Decompress run: find . -type f -name '*.tar.gz' -exec sh -c 'tar -zxf {} --one-top-level' \; - name: Publish Test Results @@ -342,7 +342,7 @@ jobs: errorprone.info:443 lightbend.github.io:443 guava.dev:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Publish Snapshot uses: ./.github/actions/run-gradle env: diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index 4784ad2cb9..ef13b0357b 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -29,7 +29,7 @@ jobs: registry-1.docker.io:443 *.blob.core.windows.net:443 - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run Codacy Analysis uses: codacy/codacy-analysis-cli-action@master continue-on-error: true @@ -47,7 +47,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' run: jq -c '.runs |= unique_by({tool, invocations, results})' < results.sarif > codacy.sarif - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 if: steps.check_files.outputs.files_exists == 'true' continue-on-error: true with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d0390c1b67..1725111ae2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -50,17 +50,17 @@ jobs: uploads.github.com:443 services.gradle.org:443 - name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Setup Gradle uses: ./.github/actions/run-gradle with: java: ${{ env.JAVA_VERSION }} token: ${{ secrets.GITHUB_TOKEN }} - name: Initialize CodeQL - uses: github/codeql-action/init@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: languages: java - name: Autobuild - uses: github/codeql-action/autobuild@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/autobuild@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/analyze@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index faaebac59e..520b671d6e 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -42,7 +42,7 @@ jobs: raw.githubusercontent.com:443 services.gradle.org:443 www.cisa.gov:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run dependency-check uses: ./.github/actions/run-gradle continue-on-error: true @@ -57,7 +57,7 @@ jobs: with: files: build/reports/dependency-check-report.sarif - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 if: steps.check_files.outputs.files_exists == 'true' with: sarif_file: build/reports/dependency-check-report.sarif diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 864cca27fa..06970d9086 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -18,9 +18,9 @@ jobs: api.github.com:443 github.com:443 - name: Checkout Repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Dependency Review - uses: actions/dependency-review-action@5bbc3ba658137598168acb2ab73b21c432dd411b # v4.2.5 + uses: actions/dependency-review-action@0659a74c94536054bfa5aeb92241f70d680cc78e # v4.3.0 with: license-check: false comment-summary-in-pr: on-failure diff --git a/.github/workflows/dependency-submission-pr-retreive.yml b/.github/workflows/dependency-submission-pr-retreive.yml index fb8e814d8c..ad6ff81df0 100644 --- a/.github/workflows/dependency-submission-pr-retreive.yml +++ b/.github/workflows/dependency-submission-pr-retreive.yml @@ -35,6 +35,6 @@ jobs: repo1.maven.org:443 services.gradle.org:443 - name: Retrieve and submit dependency graph - uses: gradle/actions/dependency-submission@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0 + uses: gradle/actions/dependency-submission@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 with: dependency-graph: download-and-submit diff --git a/.github/workflows/dependency-submission-pr-submit.yml b/.github/workflows/dependency-submission-pr-submit.yml index 6fcdccbc2e..4e904cd903 100644 --- a/.github/workflows/dependency-submission-pr-submit.yml +++ b/.github/workflows/dependency-submission-pr-submit.yml @@ -31,14 +31,14 @@ jobs: repo.maven.apache.org:443 repo1.maven.org:443 services.gradle.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: java-version: ${{ env.JAVA_VERSION }} distribution: temurin - name: Submit Dependency Graph - uses: gradle/actions/dependency-submission@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0 + uses: gradle/actions/dependency-submission@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 with: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} dependency-graph: generate-and-upload diff --git a/.github/workflows/dependency-submission.yml b/.github/workflows/dependency-submission.yml index e4fd57dc66..062c8558f9 100644 --- a/.github/workflows/dependency-submission.yml +++ b/.github/workflows/dependency-submission.yml @@ -31,13 +31,13 @@ jobs: repo.maven.apache.org:443 repo1.maven.org:443 services.gradle.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: java-version: ${{ env.JAVA_VERSION }} distribution: temurin - name: Submit Dependency Graph - uses: gradle/actions/dependency-submission@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0 + uses: gradle/actions/dependency-submission@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 with: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} diff --git a/.github/workflows/devskim.yml b/.github/workflows/devskim.yml index cde46b443a..96844c7ca1 100644 --- a/.github/workflows/devskim.yml +++ b/.github/workflows/devskim.yml @@ -27,10 +27,10 @@ jobs: api.github.com:443 github.com:443 - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run DevSkim scanner uses: microsoft/DevSkim-Action@914fa647b406c387000300b2f09bb28691be2b6d # v1.0.14 - name: Upload DevSkim scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: sarif_file: devskim-results.sarif diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 8a8048d4b0..179ce86d7e 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -32,14 +32,14 @@ jobs: repo1.maven.org:443 services.gradle.org:443 www.graalvm.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Set up JDK ${{ env.JAVA_VERSION }} uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: java-version: ${{ env.JAVA_VERSION }} distribution: temurin - name: Setup Gradle - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 with: add-job-summary: never cache-read-only: false diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml index 4fe7046b4d..712b7dcd50 100644 --- a/.github/workflows/gitleaks.yml +++ b/.github/workflows/gitleaks.yml @@ -23,7 +23,7 @@ jobs: egress-policy: block allowed-endpoints: ${{ env.ALLOWED_ENDPOINTS }} - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: fetch-depth: 0 - name: Run gitleaks diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 082aef2434..772f63040f 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -17,5 +17,5 @@ jobs: downloads.gradle-dn.com:443 github.com:443 services.gradle.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - uses: gradle/actions/wrapper-validation@6cec5d49d4d6d4bb982fbed7047db31ea6d38f11 # v3.3.0 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml index e705a6da04..844e942cfc 100644 --- a/.github/workflows/qodana.yml +++ b/.github/workflows/qodana.yml @@ -52,17 +52,19 @@ jobs: resources.jetbrains.com:443 services.gradle.org:443 - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Build uses: ./.github/actions/run-gradle with: java: ${{ env.JAVA_VERSION }} arguments: build -x test - name: Qodana - Code Inspection - uses: JetBrains/qodana-action@a040a784cc28cb9cabdf884c4e8c32d0aa3fcdb3 # v2023.3.2 + uses: JetBrains/qodana-action@2dbc4103d1a75b11de914a893bf1bd03a88a5ce1 # v2024.1.2 + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} with: upload-result: true - name: Upload SARIF file for GitHub Advanced Security Dashboard - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61fd1fa8ab..14a1599f1d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: with: disable-sudo: true egress-policy: audit - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Releasing uses: ./.github/actions/run-gradle env: diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 5c22e74d7d..c54e4c2c98 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -37,7 +37,7 @@ jobs: tuf-repo-cdn.sigstore.dev:443 www.bestpractices.dev:443 - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: persist-credentials: false - name: Run analysis @@ -48,12 +48,12 @@ jobs: results_file: results.sarif repo_token: ${{ secrets.SCORECARD_READ_TOKEN }} - name: Upload artifact - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: SARIF file path: results.sarif retention-days: 5 - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: sarif_file: results.sarif diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index 288dadf7e1..0c4463abac 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -17,7 +17,7 @@ jobs: # Incompatible with Harden Runner image: returntocorp/semgrep steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - run: semgrep scan --sarif --output=results.sarif env: SEMGREP_RULES: >- @@ -34,7 +34,7 @@ jobs: if: steps.check_files.outputs.files_exists == 'true' run: jq -c '.runs[0].tool.driver.rules |= unique_by(.id)' < results.sarif > semgrep.sarif - name: Upload SARIF file for GitHub Advanced Security Dashboard - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 if: steps.check_files.outputs.files_exists == 'true' continue-on-error: true with: diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml index 56904297c2..ecba5044b3 100644 --- a/.github/workflows/snyk.yml +++ b/.github/workflows/snyk.yml @@ -37,7 +37,7 @@ jobs: repo.maven.apache.org:443 repo1.maven.org:443 services.gradle.org:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run Snyk test uses: snyk/actions/gradle-jdk17@master continue-on-error: true @@ -52,7 +52,7 @@ jobs: with: files: snyk.sarif - name: Upload result to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 if: steps.check_files.outputs.files_exists == 'true' with: sarif_file: snyk.sarif diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml index 9cbb000164..902d60a7ab 100644 --- a/.github/workflows/spelling.yml +++ b/.github/workflows/spelling.yml @@ -14,7 +14,7 @@ jobs: allowed-endpoints: > api.github.com:443 github.com:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Misspell uses: reviewdog/action-misspell@5bd7be2fc7ae56a517184f5c4bbcf2fd7afe3927 # v1.17.0 with: @@ -32,6 +32,6 @@ jobs: allowed-endpoints: > github.com:443 objects.githubusercontent.com:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Typos - uses: crate-ci/typos@efad85b292e13df995ff2476013baaa5f1c30459 # v1.20.8 + uses: crate-ci/typos@f2c1f08a7b3c1b96050cb786baaa2a94797bdb7d # v1.20.10 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 0505926474..fc960f1f03 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -21,7 +21,7 @@ jobs: ghcr.io:443 github.com:443 pkg-containers.githubusercontent.com:443 - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 # v0.19.0 with: @@ -29,6 +29,6 @@ jobs: format: sarif output: trivy-results.sarif - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3.24.10 + uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 with: sarif_file: trivy-results.sarif diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/TimerWheelBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/TimerWheelBenchmark.java index e5cc046577..bc0f6192bf 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/TimerWheelBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/TimerWheelBenchmark.java @@ -33,6 +33,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) +@SuppressWarnings("ClassEscapesDefinedScope") public class TimerWheelBenchmark { private static final int SIZE = (2 << 14); private static final int MASK = SIZE - 1; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/Ehcache3.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/Ehcache3.java index 7c7f2d1dcc..bbf07d6d46 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/Ehcache3.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/Ehcache3.java @@ -16,10 +16,8 @@ package com.github.benmanes.caffeine.cache.impl; import org.ehcache.Cache; -import org.ehcache.CacheManager; -import org.ehcache.config.builders.CacheConfigurationBuilder; -import org.ehcache.config.builders.CacheManagerBuilder; import org.ehcache.config.builders.ResourcePoolsBuilder; +import org.ehcache.config.builders.UserManagedCacheBuilder; import org.ehcache.config.units.EntryUnit; import com.github.benmanes.caffeine.cache.BasicCache; @@ -32,12 +30,12 @@ public final class Ehcache3 implements BasicCache { @SuppressWarnings({"PMD.CloseResource", "unchecked"}) public Ehcache3(int maximumSize) { - CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build(true); - cache = (Cache) cacheManager.createCache("benchmark", - CacheConfigurationBuilder.newCacheConfigurationBuilder(Object.class, Object.class, - ResourcePoolsBuilder.newResourcePoolsBuilder() - .heap(maximumSize, EntryUnit.ENTRIES)) - .build()); + var resourcesPools = ResourcePoolsBuilder.newResourcePoolsBuilder() + .heap(maximumSize, EntryUnit.ENTRIES); + cache = (Cache) UserManagedCacheBuilder + .newUserManagedCacheBuilder(Object.class, Object.class) + .withResourcePools(resourcesPools) + .build(true); } @Override diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/TCache.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/TCache.java index 2500cbab86..66208859e1 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/TCache.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/TCache.java @@ -28,8 +28,10 @@ public final class TCache implements BasicCache { private final Cache cache; + @SuppressWarnings({"PMD.CloseResource", "resource"}) public TCache(int maximumSize, EvictionPolicy policy) { - cache = TCacheFactory.standardFactory().builder() + var factory = new TCacheFactory(); + cache = factory.builder() .setConcurrencyLevel(CONCURRENCY_LEVEL) .setMaxElements(maximumSize) .setEvictionPolicy(policy) diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCacheLoader.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCacheLoader.java index 7004b6bd41..b2c0948611 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCacheLoader.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCacheLoader.java @@ -38,6 +38,8 @@ * AsyncLoadingCache cache = Caffeine.newBuilder().buildAsync(loader); * } * + * @param the type of keys + * @param the type of values * @author ben.manes@gmail.com (Ben Manes) */ @FunctionalInterface diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java index d0b44963c8..bbd2073a1e 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java @@ -3974,7 +3974,7 @@ private Object writeReplace() { } } - @SuppressWarnings("NullableOptional") + @SuppressWarnings({"NullableOptional", "OptionalAssignedToNull"}) static final class BoundedPolicy implements Policy { final BoundedLocalCache cache; final Function transformer; @@ -4002,6 +4002,7 @@ static final class BoundedPolicy implements Policy { Node node = cache.data.get(cache.nodeFactory.newLookupKey(key)); return (node == null) ? null : cache.nodeToCacheEntry(node, transformer); } + @SuppressWarnings("Java9CollectionFactory") @Override public Map> refreshes() { var refreshes = cache.refreshes; if ((refreshes == null) || refreshes.isEmpty()) { diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java index 42bdfd02fa..84e842fa6a 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java @@ -39,6 +39,8 @@ * LoadingCache cache = Caffeine.newBuilder().build(loader); * } * + * @param the type of keys + * @param the type of values * @author ben.manes@gmail.com (Ben Manes) */ @FunctionalInterface diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java index fa0f5512c7..588b0242d6 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java @@ -496,7 +496,7 @@ long getMaximum() { return isWeighted() ? maximumWeight : maximumSize; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"JavaAnnotator", "unchecked"}) Weigher getWeigher(boolean isAsync) { Weigher delegate = (weigher == null) || (weigher == Weigher.singletonWeigher()) ? Weigher.singletonWeigher() @@ -912,7 +912,7 @@ public Caffeine evictionListener( return self; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"JavaAnnotator", "unchecked"}) @Nullable RemovalListener getEvictionListener( boolean async) { var castedListener = (RemovalListener) evictionListener; @@ -964,7 +964,7 @@ public Caffeine removalListener( return self; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"JavaAnnotator", "unchecked"}) @Nullable RemovalListener getRemovalListener(boolean async) { RemovalListener castedListener = (RemovalListener) removalListener; return async && (castedListener != null) diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Expiry.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Expiry.java index 25f254165b..bdeaccd87a 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Expiry.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Expiry.java @@ -38,6 +38,8 @@ * .build(key -> createExpensiveGraph(key)); * } * + * @param the type of keys + * @param the type of values * @author ben.manes@gmail.com (Ben Manes) */ public interface Expiry { @@ -104,6 +106,8 @@ public interface Expiry { * Duration.between(Instant.now(), graph.createdOn().plusHours(5))); * } * + * @param the key type + * @param the value type * @param function the function used to calculate the length of time after an entry is created * before it should be automatically removed * @return an {@code Expiry} instance with the specified expiry function @@ -122,6 +126,8 @@ static Expiry creating(BiFunction function) { * Duration.between(Instant.now(), graph.modifiedOn().plusHours(5))); * } * + * @param the key type + * @param the value type * @param function the function used to calculate the length of time after an entry is created * or updated that it should be automatically removed * @return an {@code Expiry} instance with the specified expiry function @@ -140,6 +146,8 @@ static Expiry writing(BiFunction function) { * graph.isDirected() ? Duration.ofHours(1) : Duration.ofHours(3)); * } * + * @param the key type + * @param the value type * @param function the function used to calculate the length of time after an entry last accessed * that it should be automatically removed * @return an {@code Expiry} instance with the specified expiry function diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java index a13715a593..7c83f97a16 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java @@ -445,6 +445,7 @@ public boolean replace(K key, CompletableFuture oldValue, CompletableFuture>> entrySet() { return asyncCache.cache().entrySet(); } + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object o) { return asyncCache.cache().equals(o); } diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCacheFactory.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCacheFactory.java index 0123856a4b..d5b13a4ce7 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCacheFactory.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalCacheFactory.java @@ -121,8 +121,7 @@ final class MethodHandleBasedFactory implements LocalCacheFactory { MethodHandleBasedFactory(Class clazz) throws NoSuchMethodException, IllegalAccessException { this.methodHandle = LOOKUP.findConstructor(clazz, FACTORY).asType(FACTORY_CALL); } - - @SuppressWarnings("unchecked") + @SuppressWarnings({"ClassEscapesDefinedScope", "unchecked"}) @Override public BoundedLocalCache newInstance(Caffeine builder, @Nullable AsyncCacheLoader cacheLoader, boolean async) throws Throwable { return (BoundedLocalCache) methodHandle.invokeExact(builder, cacheLoader, async); diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueue.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueue.java index 30799f7829..1ecb641387 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueue.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueue.java @@ -315,7 +315,7 @@ else if (casProducerIndex(this, pIndex, pIndex + 1)) { * This implementation is correct for single consumer thread use only. */ @Override - @SuppressWarnings("unchecked") + @SuppressWarnings({"CastCanBeRemovedNarrowingVariableType", "unchecked"}) public E poll() { final E[] buffer = consumerBuffer; final long index = consumerIndex; @@ -349,8 +349,8 @@ public E poll() { *

* This implementation is correct for single consumer thread use only. */ - @SuppressWarnings("unchecked") @Override + @SuppressWarnings({"CastCanBeRemovedNarrowingVariableType", "unchecked"}) public E peek() { final E[] buffer = consumerBuffer; final long index = consumerIndex; @@ -363,7 +363,7 @@ public E peek() { // check the producer index. If the queue is indeed not empty we spin until element is // visible. while ((e = lvElement(buffer, offset)) == null) { - ; + // retry } } if (e == JUMP) { @@ -467,7 +467,7 @@ public boolean relaxedOffer(E e) { return offer(e); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"CastCanBeRemovedNarrowingVariableType", "unchecked"}) public E relaxedPoll() { final E[] buffer = consumerBuffer; final long index = consumerIndex; @@ -487,7 +487,7 @@ public E relaxedPoll() { return (E) e; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"CastCanBeRemovedNarrowingVariableType", "unchecked"}) public E relaxedPeek() { final E[] buffer = consumerBuffer; final long index = consumerIndex; @@ -572,7 +572,7 @@ static void soProducerLimit(BaseMpscLinkedArrayQueue self, long v) { P_LIMIT.setRelease(self, v); } - /** + /* * A concurrent access enabling class used by circular array based queues this class exposes an * offset computation method along with differently memory fenced load/store methods into the * underlying array. The class is pre-padded and the array is padded on either side to help with diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java index 6aea53eef9..eff0a3329c 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java @@ -38,6 +38,8 @@ * characteristics. These operations are optional and dependent on how the cache was constructed * and what abilities the implementation exposes. * + * @param the type of keys + * @param the type of values * @author ben.manes@gmail.com (Ben Manes) */ public interface Policy { @@ -149,7 +151,12 @@ default CacheEntry getEntryIfPresentQuietly(K key) { */ Optional> refreshAfterWrite(); - /** The low-level operations for a cache with a size-based eviction policy. */ + /** + * The low-level operations for a cache with a size-based eviction policy. + * + * @param the type of keys + * @param the type of values + */ interface Eviction { /** @@ -332,7 +339,12 @@ default T hottest(Function>, T> mappingFunction) { } } - /** The low-level operations for a cache with a fixed expiration policy. */ + /** + * The low-level operations for a cache with a fixed expiration policy. + * + * @param the type of keys + * @param the type of values + */ interface FixedExpiration { /** @@ -504,7 +516,12 @@ default T youngest(Function>, T> mappingFunction) { } } - /** The low-level operations for a cache with a variable expiration policy. */ + /** + * The low-level operations for a cache with a variable expiration policy. + * + * @param the type of keys + * @param the type of values + */ interface VarExpiration { /** @@ -745,7 +762,12 @@ default T youngest(Function>, T> mappingFunction) { } } - /** The low-level operations for a cache with a fixed refresh policy. */ + /** + * The low-level operations for a cache with a fixed refresh policy. + * + * @param the type of keys + * @param the type of values + */ interface FixedRefresh { /** @@ -836,6 +858,9 @@ default void setRefreshesAfter(Duration duration) { * specified, this is a value-based class, it can be assumed that the implementation is an * immutable snapshot of the cached data at the time of this entry's creation, and it will not * reflect changes afterward. + * + * @param the type of keys + * @param the type of values */ interface CacheEntry extends Map.Entry { diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/References.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/References.java index 5987244f17..54b261a3db 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/References.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/References.java @@ -30,7 +30,8 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass") +@SuppressWarnings({"EqualsWhichDoesntCheckParameterClass", + "PMD.MissingStaticMethodInNonInstantiatableClass"}) final class References { private References() {} diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java index ed8187bfac..03378aaba1 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java @@ -545,6 +545,7 @@ public boolean replace(K key, V oldValue, V newValue, boolean shouldDiscardRefre } @Override + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") public boolean equals(Object o) { return (o == this) || data.equals(o); } @@ -1079,6 +1080,7 @@ static final class UnboundedPolicy implements Policy { V value = transformer.apply(cache.data.get(key)); return (value == null) ? null : SnapshotEntry.forEntry(key, value); } + @SuppressWarnings("Java9CollectionFactory") @Override public Map> refreshes() { var refreshes = cache.refreshes; if ((refreshes == null) || refreshes.isEmpty()) { diff --git a/caffeine/src/main/java/module-info.java b/caffeine/src/main/java/module-info.java index a257871517..28fbf809f8 100644 --- a/caffeine/src/main/java/module-info.java +++ b/caffeine/src/main/java/module-info.java @@ -1,3 +1,4 @@ +/** This module contains in-memory caching functionality. */ module com.github.benmanes.caffeine { exports com.github.benmanes.caffeine.cache; exports com.github.benmanes.caffeine.cache.stats; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedBufferTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedBufferTest.java index 95ac10a7e1..e108d90eb6 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedBufferTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedBufferTest.java @@ -31,6 +31,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class BoundedBufferTest { @DataProvider diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedLocalCacheTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedLocalCacheTest.java index d8acd49509..396fec48a9 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedLocalCacheTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/BoundedLocalCacheTest.java @@ -148,9 +148,9 @@ * @author ben.manes@gmail.com (Ben Manes) */ @CheckMaxLogLevel(WARN) -@SuppressWarnings("GuardedBy") @Listeners(CacheValidationListener.class) @Test(dataProviderClass = CacheProvider.class) +@SuppressWarnings({"ClassEscapesDefinedScope", "GuardedBy"}) public final class BoundedLocalCacheTest { @Test(dataProvider = "caches") diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/FrequencySketchTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/FrequencySketchTest.java index c99ca0c9f4..442a87be1d 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/FrequencySketchTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/FrequencySketchTest.java @@ -26,6 +26,7 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class FrequencySketchTest { final Integer item = ThreadLocalRandom.current().nextInt(); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LinkedDequeTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LinkedDequeTest.java index 7e071ed234..922cae7679 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LinkedDequeTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LinkedDequeTest.java @@ -45,6 +45,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class LinkedDequeTest { static final int SIZE = 100; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LocalCacheSubject.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LocalCacheSubject.java index 658f773e04..a289888584 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LocalCacheSubject.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/LocalCacheSubject.java @@ -400,7 +400,7 @@ private void checkRefreshAfterWrite( /* --------------- Unbounded --------------- */ - public void checkUnbounded(UnboundedLocalCache unbounded) { + private void checkUnbounded(UnboundedLocalCache unbounded) { if (unbounded.isEmpty()) { check("unbounded").about(map()).that(unbounded).isExhaustivelyEmpty(); } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueueTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueueTest.java index 5650898b90..05d976c33f 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueueTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/MpscGrowableArrayQueueTest.java @@ -30,6 +30,7 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class MpscGrowableArrayQueueTest { private static final int NUM_PRODUCERS = 10; private static final int PRODUCE = 100; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/QueueSanityTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/QueueSanityTest.java index 977c468f54..08e3522e63 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/QueueSanityTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/QueueSanityTest.java @@ -296,7 +296,7 @@ public static Matcher> emptyAndZeroSize() { return allOf(hasSize(0), empty()); } - enum Ordering { + public enum Ordering { FIFO } } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/ReferenceTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/ReferenceTest.java index 93b45250c2..4498aa2195 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/ReferenceTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/ReferenceTest.java @@ -1251,6 +1251,7 @@ private static Map parseToString(Map map) { /* --------------- Reference --------------- */ + @SuppressWarnings("ClassEscapesDefinedScope") @Test(dataProviderClass = ReferenceTest.class, dataProvider = "references") public void reference(InternalReference reference, Int item, boolean identity, boolean isKey) { diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/StripedBufferTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/StripedBufferTest.java index c8d40d1255..10711c1057 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/StripedBufferTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/StripedBufferTest.java @@ -33,6 +33,7 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class StripedBufferTest { static final Integer ELEMENT = 1; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java index 8029ad2e96..7a04601e88 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java @@ -64,7 +64,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @Test(singleThreaded = true) -@SuppressWarnings("GuardedBy") +@SuppressWarnings({"ClassEscapesDefinedScope", "GuardedBy"}) public final class TimerWheelTest { private static final Random random = new Random(); private static final long[] CLOCKS = { Long.MIN_VALUE, -SPANS[0] + 1, 0L, diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java index 3ef80750a9..d72a3f1698 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheGenerator.java @@ -64,7 +64,7 @@ public CacheGenerator(CacheSpec cacheSpec) { /* isLoadingOnly */ false, /* isAsyncOnly */ false, /* isGuavaCompatible */ true); } - public CacheGenerator(CacheSpec cacheSpec, Options options, + CacheGenerator(CacheSpec cacheSpec, Options options, boolean isLoadingOnly, boolean isAsyncOnly, boolean isGuavaCompatible) { this.isGuavaCompatible = isGuavaCompatible; this.isLoadingOnly = isLoadingOnly; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java index 8c26b9f6ed..847c8b9625 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java @@ -317,7 +317,6 @@ enum Expire { /** A configuration where entries are after a time duration. */ ONE_MINUTE(TimeUnit.MINUTES.toNanos(1)), /** A configuration where entries should never expire. */ - /** A configuration that holds the {@link Population#FULL} count. */ FOREVER(Long.MAX_VALUE); private final long timeNanos; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java index 685476a867..03aabb736a 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java @@ -209,6 +209,7 @@ public void testGenericComparable2() { } for (int i = 0; i < size; i++) { + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") LexicographicList bis = new LexicographicList<>(new BI(i)); assertTrue(m.containsKey(bis)); } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java index 7357cfb7fb..08ed20235e 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java @@ -187,11 +187,11 @@ * * */ -@SuppressWarnings({"AnnotateFormatMethod", "CollectionToArray", "EqualsIncompatibleType", - "FunctionalInterfaceClash", "JavaUtilDate", "JUnit3FloatingPointComparisonWithoutDelta", - "NonFinalStaticField", "NumericEquality", "rawtypes", "ReferenceEquality", - "RethrowReflectiveOperationExceptionAsLinkageError", "serial", "SwitchDefault", - "ThreadPriorityCheck", "try", "unchecked", "UndefinedEquals"}) +@SuppressWarnings({"AnnotateFormatMethod", "ClassEscapesDefinedScope", "CollectionToArray", + "EqualsIncompatibleType", "FunctionalInterfaceClash", "JavaUtilDate", + "JUnit3FloatingPointComparisonWithoutDelta", "NonFinalStaticField", "NumericEquality", + "rawtypes", "ReferenceEquality", "RethrowReflectiveOperationExceptionAsLinkageError", + "serial", "SwitchDefault", "ThreadPriorityCheck", "try", "unchecked", "UndefinedEquals"}) public class JSR166TestCase extends TestCase { // private static final boolean useSecurityManager = // Boolean.getBoolean("jsr166.useSecurityManager"); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 138950102f..09d1f04bc7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ bouncycastle-jdk18on = "1.78" cache2k = "2.6.1.Final" caffeine = "3.1.8" checker-framework = "3.42.0" -checkstyle = "10.15.0" +checkstyle = "10.16.0" coherence = "22.06.2" commons-collections4 = "4.4" commons-compress = "1.26.1" @@ -89,7 +89,7 @@ spotbugs-core = "4.8.4" spotbugs-plugin = "6.0.12" stream = "2.9.8" tcache = "2.0.1" -testng = "7.10.1" +testng = "7.10.2" truth = "1.4.2" univocity-parsers = "2.9.1" versions = "0.51.0" diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts index bb720de2da..8361b62e04 100644 --- a/gradle/plugins/build.gradle.kts +++ b/gradle/plugins/build.gradle.kts @@ -16,7 +16,6 @@ plugins { alias(libs.plugins.versions) } -require(JavaVersion.current() >= JavaVersion.VERSION_17) { "Java 17 or greater is required" } java.toolchain.languageVersion = JavaLanguageVersion.of(17) dependencies { diff --git a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java index 0c7da97a5c..b102802858 100644 --- a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java +++ b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java @@ -243,8 +243,10 @@ static final class CacheLoaderException extends RuntimeException { CacheLoaderException(Exception e) { super(e); } + @CanIgnoreReturnValue - @SuppressWarnings({"lgtm [java/non-sync-override]", "UnsynchronizedOverridesSynchronized"}) + @SuppressWarnings({"NonSynchronizedMethodOverridesSynchronizedMethod", + "UnsynchronizedOverridesSynchronized"}) @Override public Throwable fillInStackTrace() { return this; } diff --git a/guava/src/main/java/module-info.java b/guava/src/main/java/module-info.java index 79ee06a2a0..9558b39cc6 100644 --- a/guava/src/main/java/module-info.java +++ b/guava/src/main/java/module-info.java @@ -1,3 +1,5 @@ +/** This module contains an adapter to the Guava cache interfaces. */ +@SuppressWarnings("requires-transitive-automatic") module com.github.benmanes.caffeine.guava { requires transitive com.github.benmanes.caffeine; requires transitive com.google.common; diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java index 8f8d70860a..0adc36ccf1 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java @@ -1251,7 +1251,7 @@ public void remove() { } } - private static final class PutResult { + protected static final class PutResult { @Nullable V oldValue; boolean written; } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurator.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurator.java index 0545953cc2..d71f25f6d1 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurator.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurator.java @@ -121,7 +121,7 @@ public static Optional> from(Config config, S * @param factoryCreator the strategy for creating a factory */ @Inject - @SuppressWarnings("UnnecessarilyVisible") + @SuppressWarnings({"deprecation", "UnnecessarilyVisible"}) public static void setFactoryCreator(FactoryCreator factoryCreator) { TypesafeConfigurator.factoryCreator = requireNonNull(factoryCreator); } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/copy/AbstractCopier.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/copy/AbstractCopier.java index ab36f27882..c35d0dd799 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/copy/AbstractCopier.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/copy/AbstractCopier.java @@ -129,6 +129,7 @@ private boolean isArrayOfImmutableTypes(Class clazz) { } /** @return a shallow copy of the array. */ + @SuppressWarnings("SuspiciousSystemArraycopy") private static T arrayCopy(T object) { int length = Array.getLength(object); @SuppressWarnings("unchecked") diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/Registration.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/Registration.java index 6299b5404f..c55ec09bb5 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/Registration.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/Registration.java @@ -27,6 +27,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("ClassEscapesDefinedScope") public final class Registration { private final CacheEntryListenerConfiguration configuration; private final EventTypeAwareListener listener; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/CaffeineCachingProviderTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/CaffeineCachingProviderTest.java index 8b6e59582f..655679a155 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/CaffeineCachingProviderTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/CaffeineCachingProviderTest.java @@ -16,14 +16,11 @@ package com.github.benmanes.caffeine.jcache.spi; import static com.google.common.truth.Truth.assertThat; -import static org.awaitility.Awaitility.await; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.nullValue; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.io.UncheckedIOException; +import java.time.Duration; import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; @@ -34,6 +31,7 @@ import org.testng.annotations.Test; import com.github.benmanes.caffeine.jcache.configuration.CaffeineConfiguration; +import com.google.common.util.concurrent.Uninterruptibles; /** * @author ben.manes@gmail.com (Ben Manes) @@ -130,17 +128,18 @@ public void osgi_getCache() { } private void runWithClassloader(Consumer consumer) { - var provider = new AtomicReference(); - new Thread(() -> { + var reference = new AtomicReference(); + var thread = new Thread(() -> { Thread.currentThread().setContextClassLoader(new ClassLoader() {}); - provider.set(new CaffeineCachingProvider()); - }).start(); - await().untilAtomic(provider, is(not(nullValue()))); + reference.set(new CaffeineCachingProvider()); + }); + thread.start(); + Uninterruptibles.joinUninterruptibly(thread, Duration.ofMinutes(1)); var classLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(new ClassLoader() {}); - try { - consumer.accept(provider.get()); + try (var provider = reference.get()) { + consumer.accept(provider); } finally { Thread.currentThread().setContextClassLoader(classLoader); } diff --git a/qodana.yaml b/qodana.yaml index df311fd7f9..1a9455ea5c 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -1,42 +1,27 @@ version: "1.0" profile: name: qodana.recommended +licenseRules: + - keys: [ Apache-2.0 ] + allowed: [ LGPL-3.0-only ] exclude: - - name: AutoCloseableResource - - name: CastCanBeRemovedNarrowingVariableType - - name: ClassEscapesItsScope - name: CommentedOutCode - name: ConstantValue - - name: DanglingJavadoc - name: DataFlowIssue - - name: Deprecation + - name: DuplicatedCode - name: EmptyStatementBody - - name: EqualsWhichDoesntCheckParameterClass - - name: GroovyEmptyStatementBody - - name: GroovyUnnecessaryReturn - - name: GrUnnecessarySemicolon - name: IgnoreResultOfCall - - name: Java9CollectionFactory - - name: JavaAnnotator - name: JavadocLinkAsPlainText - - name: JavaRequiresAutoModule - - name: MismatchedCollectionQueryUpdate - - name: NonSynchronizedMethodOverridesSynchronizedMethod - name: NotNullFieldNotInitialized - name: NullableProblems - - name: OptionalAssignedToNull - name: OptionalUsedAsFieldOrParameterType - name: PackageDirectoryMismatch - name: RedundantCollectionOperation - name: RedundantUnmodifiable - - name: ReplaceAssignmentWithOperatorAssignment - name: ReturnNull - - name: SuspiciousSystemArraycopy - name: SynchronizationOnLocalVariableOrMethodParameter - name: SystemOutErr - name: TrivialIf - name: UnnecessaryReturn - - name: UnnecessarySemicolon - - name: UnsatisfiedRange + - name: UnreachableCode - name: UnstableApiUsage - - name: WhileLoopSpinsOnField diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/Simulate.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/Simulate.java index ccddfec828..01ed42afae 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/Simulate.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/Simulate.java @@ -58,6 +58,7 @@ */ @Command(mixinStandardHelpOptions = true) public final class Simulate implements Runnable { + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") @Option(names = "--maximumSize", required = true, split = ",", description = "The maximum sizes", preprocessor = LongPreprocessor.class) private SortedSet maximumSizes; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/HashFunctionParser.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/HashFunctionParser.java index 76f9e4f914..3223ec6612 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/HashFunctionParser.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/HashFunctionParser.java @@ -23,7 +23,7 @@ * * @author gilga1983@gmail.com (Gil Einziger) */ -public final class HashFunctionParser { +final class HashFunctionParser { // currently, chain is bounded to be 64. private static final int fpSize = 8; // this implementation assumes byte. private static final byte fpMask = (byte) 255; // (all bits in byte are 1, (logical value of -1)); @@ -32,7 +32,7 @@ public final class HashFunctionParser { private static final long Seed64 = 0xe17a1465L; private static final int r = 47; - public final HashedItem fpaux; // used just to avoid allocating new memory as a return value. + final HashedItem fpaux; // used just to avoid allocating new memory as a return value. private final int nrSets; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/BinaryTraceWriter.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/BinaryTraceWriter.java deleted file mode 100644 index c98ca5a2b2..0000000000 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/BinaryTraceWriter.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2021 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.simulator.parser; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * A skeletal implementation that writes to the trace file as binary data. - * - * @author ben.manes@gmail.com (Ben Manes) - */ -public abstract class BinaryTraceWriter implements TraceWriter { - private final DataOutputStream writer; - - protected BinaryTraceWriter(OutputStream output) { - this.writer = new DataOutputStream(output); - } - - protected DataOutputStream writer() { - return writer; - } - - @Override - public void close() throws IOException { - writer.close(); - } -} diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/TextTraceWriter.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/TextTraceWriter.java deleted file mode 100644 index df2ed739a7..0000000000 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/TextTraceWriter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.simulator.parser; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -/** - * A skeletal implementation that writes to the trace file as textual data. - * - * @author ben.manes@gmail.com (Ben Manes) - */ -public abstract class TextTraceWriter implements TraceWriter { - private final BufferedWriter writer; - - protected TextTraceWriter(OutputStream output) { - this.writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8)); - } - - protected BufferedWriter writer() { - return writer; - } - - @Override - public void close() throws IOException { - writer.close(); - } -} diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/adapt_size/AdaptSizeTraceWriter.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/adapt_size/AdaptSizeTraceWriter.java index 181b005685..97eae7ac53 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/adapt_size/AdaptSizeTraceWriter.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/adapt_size/AdaptSizeTraceWriter.java @@ -15,10 +15,14 @@ */ package com.github.benmanes.caffeine.cache.simulator.parser.adapt_size; +import static java.nio.charset.StandardCharsets.UTF_8; + +import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; +import java.io.OutputStreamWriter; -import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceWriter; +import com.github.benmanes.caffeine.cache.simulator.parser.TraceWriter; import com.github.benmanes.caffeine.cache.simulator.policy.AccessEvent; /** @@ -26,19 +30,25 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -public final class AdaptSizeTraceWriter extends TextTraceWriter { +public final class AdaptSizeTraceWriter implements TraceWriter { + private final BufferedWriter writer; public AdaptSizeTraceWriter(OutputStream output) { - super(output); + this.writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8)); } @Override public void writeEvent(int tick, AccessEvent event) throws IOException { - writer().write(Long.toString(tick)); - writer().write(" "); - writer().write(Long.toString(event.key())); - writer().write(" "); - writer().write(Integer.toString(event.weight())); - writer().newLine(); + writer.write(Long.toString(tick)); + writer.write(" "); + writer.write(Long.toString(event.key())); + writer.write(" "); + writer.write(Integer.toString(event.weight())); + writer.newLine(); + } + + @Override + public void close() throws IOException { + writer.close(); } } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/cloud_physics/CloudPhysicsTraceWriter.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/cloud_physics/CloudPhysicsTraceWriter.java index d074f4f825..f38910204c 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/cloud_physics/CloudPhysicsTraceWriter.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/cloud_physics/CloudPhysicsTraceWriter.java @@ -15,10 +15,11 @@ */ package com.github.benmanes.caffeine.cache.simulator.parser.cloud_physics; +import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; -import com.github.benmanes.caffeine.cache.simulator.parser.BinaryTraceWriter; +import com.github.benmanes.caffeine.cache.simulator.parser.TraceWriter; import com.github.benmanes.caffeine.cache.simulator.policy.AccessEvent; import com.google.common.hash.Hashing; @@ -27,15 +28,21 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -public final class CloudPhysicsTraceWriter extends BinaryTraceWriter { +public final class CloudPhysicsTraceWriter implements TraceWriter { + private final DataOutputStream writer; public CloudPhysicsTraceWriter(OutputStream output) { - super(output); + this.writer = new DataOutputStream(output); } @Override public void writeEvent(int tick, AccessEvent event) throws IOException { int key = Hashing.murmur3_128().hashLong(event.key()).asInt(); - writer().writeInt(key); + writer.writeInt(key); + } + + @Override + public void close() throws IOException { + writer.close(); } } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/lirs/LirsTraceWriter.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/lirs/LirsTraceWriter.java index 059f7e2196..76b87f1b70 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/lirs/LirsTraceWriter.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/lirs/LirsTraceWriter.java @@ -15,10 +15,14 @@ */ package com.github.benmanes.caffeine.cache.simulator.parser.lirs; +import static java.nio.charset.StandardCharsets.UTF_8; + +import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; +import java.io.OutputStreamWriter; -import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceWriter; +import com.github.benmanes.caffeine.cache.simulator.parser.TraceWriter; import com.github.benmanes.caffeine.cache.simulator.policy.AccessEvent; /** @@ -26,15 +30,21 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -public final class LirsTraceWriter extends TextTraceWriter { +public final class LirsTraceWriter implements TraceWriter { + private final BufferedWriter writer; public LirsTraceWriter(OutputStream output) { - super(output); + this.writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8)); } @Override public void writeEvent(int tick, AccessEvent event) throws IOException { - writer().write(Long.toString(event.key())); - writer().newLine(); + writer.write(Long.toString(event.key())); + writer.newLine(); + } + + @Override + public void close() throws IOException { + writer.close(); } } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/DClockPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/DClockPolicy.java index e281be1688..e271935494 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/DClockPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/DClockPolicy.java @@ -304,7 +304,7 @@ public String toString() { } } - static final class DClockSettings extends BasicSettings { + public static final class DClockSettings extends BasicSettings { public DClockSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CoherencePolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CoherencePolicy.java index d022c8a63a..50c740b715 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CoherencePolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CoherencePolicy.java @@ -108,7 +108,7 @@ private static final class AccessEventCalculator implements UnitCalculator { } } - static final class CoherenceSettings extends BasicSettings { + public static final class CoherenceSettings extends BasicSettings { public CoherenceSettings(Config config) { super(config); } @@ -130,7 +130,7 @@ public Set policy() { } @SuppressWarnings("deprecation") - enum Eviction { + public enum Eviction { HYBRID(LocalCache.EVICTION_POLICY_HYBRID), LRU(LocalCache.EVICTION_POLICY_LRU), LFU(LocalCache.EVICTION_POLICY_LFU); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ExpiringMapPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ExpiringMapPolicy.java index a45df853c0..c84c752a04 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ExpiringMapPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/ExpiringMapPolicy.java @@ -77,7 +77,7 @@ public PolicyStats stats() { return policyStats; } - static final class ExpiringMapSettings extends BasicSettings { + public static final class ExpiringMapSettings extends BasicSettings { public ExpiringMapSettings(Config config) { super(config); } @@ -96,7 +96,7 @@ public Set policy() { } } - enum Eviction { + public enum Eviction { FIFO(ExpirationPolicy.CREATED), LRU(ExpirationPolicy.ACCESSED); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/HazelcastPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/HazelcastPolicy.java index a9166f473d..d7e754e953 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/HazelcastPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/HazelcastPolicy.java @@ -107,7 +107,7 @@ public void finished() { checkState(stats.getEvictions() == policyStats.evictionCount()); } - static final class HazelcastSettings extends BasicSettings { + public static final class HazelcastSettings extends BasicSettings { public HazelcastSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/TCachePolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/TCachePolicy.java index 7e8970484f..3c695be1af 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/TCachePolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/TCachePolicy.java @@ -40,10 +40,12 @@ public final class TCachePolicy implements KeyOnlyPolicy { private final Cache cache; private final PolicyStats policyStats; + private final TCacheFactory factory; public TCachePolicy(TCacheSettings settings, Eviction policy) { policyStats = new PolicyStats(name() + " (%s)", policy); - cache = TCacheFactory.standardFactory().builder() + factory = new TCacheFactory(); + cache = factory.builder() .setMaxElements(Math.toIntExact(settings.maximumSize())) .setEvictionPolicy(policy.type) .setStatistics(true) @@ -76,11 +78,11 @@ public PolicyStats stats() { @Override public void finished() { - cache.close(); + factory.close(); policyStats.addEvictions(cache.statistics().getEvictionCount()); } - static final class TCacheSettings extends BasicSettings { + public static final class TCacheSettings extends BasicSettings { public TCacheSettings(Config config) { super(config); } @@ -99,7 +101,7 @@ public Set policy() { } } - enum Eviction { + public enum Eviction { LRU(EvictionPolicy.LRU), LFU(EvictionPolicy.LFU); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberType.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberType.java index f94d4ab0dc..81b3a7b0dc 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberType.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/HillClimberType.java @@ -35,7 +35,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @SuppressWarnings("ImmutableEnumChecker") -enum HillClimberType { +public enum HillClimberType { // hill climbing SIMPLE(SimpleClimber::new), SIMULATED_ANNEALING(SimulatedAnnealingClimber::new), diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/feedback/FeedbackWindowTinyLfuPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/feedback/FeedbackWindowTinyLfuPolicy.java index 235650d927..3a9c775652 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/feedback/FeedbackWindowTinyLfuPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/feedback/FeedbackWindowTinyLfuPolicy.java @@ -380,7 +380,7 @@ public String toString() { } } - static final class FeedbackWindowTinyLfuSettings extends BasicSettings { + public static final class FeedbackWindowTinyLfuSettings extends BasicSettings { public FeedbackWindowTinyLfuSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/FullySegmentedWindowTinyLfuPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/FullySegmentedWindowTinyLfuPolicy.java index a9f8dc7dd8..4600368c83 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/FullySegmentedWindowTinyLfuPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/FullySegmentedWindowTinyLfuPolicy.java @@ -266,7 +266,7 @@ public String toString() { } } - static final class FullySegmentedWindowTinyLfuSettings extends BasicSettings { + public static final class FullySegmentedWindowTinyLfuSettings extends BasicSettings { public FullySegmentedWindowTinyLfuSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/LruWindowTinyLfuPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/LruWindowTinyLfuPolicy.java index f383cae109..a29310bd34 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/LruWindowTinyLfuPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/LruWindowTinyLfuPolicy.java @@ -188,7 +188,7 @@ public String toString() { } } - static final class LruWindowTinyLfuSettings extends BasicSettings { + public static final class LruWindowTinyLfuSettings extends BasicSettings { public LruWindowTinyLfuSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/RandomWindowTinyLfuPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/RandomWindowTinyLfuPolicy.java index 6e5b63c7f9..592d69557b 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/RandomWindowTinyLfuPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/RandomWindowTinyLfuPolicy.java @@ -148,7 +148,7 @@ public String toString() { } } - static final class RandomWindowTinyLfuSettings extends BasicSettings { + public static final class RandomWindowTinyLfuSettings extends BasicSettings { public RandomWindowTinyLfuSettings(Config config) { super(config); } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/S4WindowTinyLfuPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/S4WindowTinyLfuPolicy.java index 2ea8adbaa7..1a8ef765fb 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/S4WindowTinyLfuPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/segment/S4WindowTinyLfuPolicy.java @@ -243,7 +243,7 @@ public String toString() { } } - static final class S4WindowTinyLfuSettings extends BasicSettings { + public static final class S4WindowTinyLfuSettings extends BasicSettings { public S4WindowTinyLfuSettings(Config config) { super(config); }