From d2104867ea6741729f2ae86f0a8d12ab5524d244 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Fri, 2 Jan 2026 14:33:40 +0100 Subject: [PATCH] Add `SanityCheck#EqualityRulesRecipes` Signed-off-by: Vincent Potucek --- .github/actions/build/action.yml | 21 ++++++-- .../workflows/build-and-deploy-snapshot.yml | 4 +- .github/workflows/build-pull-request.yml | 31 ++++++----- .github/workflows/ci.yml | 4 +- .github/workflows/distribute.yml | 1 + .github/workflows/release-milestone.yml | 10 ++-- .github/workflows/release.yml | 14 ++--- .github/workflows/run-codeql-analysis.yml | 3 +- .github/workflows/run-system-tests.yml | 2 +- build.gradle | 3 ++ .../boot/buildpack/platform/build/Cache.java | 6 +-- .../test/resources/commands/command.groovy | 4 +- .../test/resources/dir-sample/code/app.groovy | 2 +- .../src/test/resources/scripts/closure.groovy | 2 +- .../src/test/resources/scripts/command.groovy | 4 +- .../boot/test/system/OutputCapture.java | 4 +- .../boot/test/util/TestPropertyValues.java | 2 +- gradle/plugins/config/sanity.gradle | 14 +++++ gradle/plugins/config/sanity.yml | 53 +++++++++++++++++++ .../cache/CachingOperationInvoker.java | 2 +- .../info/InfoPropertiesInfoContributor.java | 2 +- .../boot/devtools/filewatch/ChangedFile.java | 2 +- .../devtools/restart/MainMethodTests.java | 2 +- .../JettyWebServerFactoryCustomizer.java | 2 +- ...fkaListenerContainerFactoryConfigurer.java | 2 +- ...rDetailsServiceAutoConfigurationTests.java | 2 +- .../OnDatabaseInitializationCondition.java | 2 +- .../TomcatServletWebServerFactoryTests.java | 4 +- .../autoconfigure/ZipkinHttpClientSender.java | 2 +- .../testsupport/system/OutputCapture.java | 4 +- 30 files changed, 148 insertions(+), 62 deletions(-) create mode 100644 gradle/plugins/config/sanity.gradle create mode 100644 gradle/plugins/config/sanity.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index f1ac0393b980..56b922a8359f 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -1,4 +1,4 @@ -name: Build +name: Build ðŸ“Ķ description: 'Builds the project, optionally publishing it to a local deployment repository' inputs: commercial-release-repository-url: @@ -50,7 +50,7 @@ outputs: runs: using: composite steps: - - name: Prepare Gradle Build + - name: Prepare Gradle Build ⚙ïļ uses: ./.github/actions/prepare-gradle-build with: cache-read-only: ${{ inputs.gradle-cache-read-only }} @@ -59,7 +59,7 @@ runs: java-early-access: ${{ inputs.java-early-access }} java-toolchain: ${{ inputs.java-toolchain }} java-version: ${{ inputs.java-version }} - - name: Build + - name: Sanity Build ðŸ“Ķ id: build if: ${{ inputs.publish == 'false' }} shell: bash @@ -68,8 +68,19 @@ runs: COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }} COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }} COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }} - run: ./gradlew build - - name: Publish + # run: ./gradlew build + run: ./gradlew rewriteDryRun build -Dorg.gradle.jvmargs=-Xmx12G + - name: Sanity Check ðŸĶĒ + id: sanity + if: ${{ inputs.publish == 'false' }} + shell: bash + env: + COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }} + COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }} + COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }} + COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }} + run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx12G + - name: Publish ðŸ“Ą id: publish if: ${{ inputs.publish == 'true' }} shell: bash diff --git a/.github/workflows/build-and-deploy-snapshot.yml b/.github/workflows/build-and-deploy-snapshot.yml index efd72bf49ff8..da25b6b68f9f 100644 --- a/.github/workflows/build-and-deploy-snapshot.yml +++ b/.github/workflows/build-and-deploy-snapshot.yml @@ -14,9 +14,9 @@ jobs: if: ${{ github.repository == 'spring-projects/spring-boot' || github.repository == 'spring-projects/spring-boot-commercial' }} runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - - name: Build and Publish + - name: Build ðŸ“Ķ and Publish ðŸ“Ą id: build-and-publish uses: ./.github/actions/build with: diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index d3e70557a436..7395c9b5e8fa 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -1,24 +1,27 @@ -name: Build Pull Request +name: Build Pull Request 🏭ïļ on: pull_request permissions: contents: read jobs: build: - name: Build Pull Request - if: ${{ github.repository == 'spring-projects/spring-boot' }} + name: Sanity Build 🕊ïļðŸ“Ķ +# if: ${{ github.repository == 'spring-projects/spring-boot' }} runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - - name: Build + - name: Sanity Build 🕊ïļðŸ“Ķ id: build uses: ./.github/actions/build - - name: Print JVM Thread Dumps When Cancelled - if: cancelled() - uses: ./.github/actions/print-jvm-thread-dumps - - name: Upload Build Reports - if: failure() - uses: actions/upload-artifact@v6 - with: - name: build-reports - path: '**/build/reports/' +# - name: Log Potentially Canceled JVM Thread Dumps 📋 +# if: cancelled() +# uses: ./.github/actions/print-jvm-thread-dumps +# - name: Upload Build Report 📊 +# if: failure() +# uses: actions/upload-artifact@v6 +# with: +# name: build-reports +# path: '**/build/reports/' +# - name: Sanity 🕊ïļ +# id: sanity +# uses: ./.github/actions/build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 172284667e32..c6f0ea21789b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,9 +39,9 @@ jobs: git config --global core.autocrlf true git config --global core.longPaths true Stop-Service -name Docker - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - - name: Build + - name: Build ðŸ“Ķ id: build uses: ./.github/actions/build with: diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index e8462178fe5c..d8250fe4300f 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -19,6 +19,7 @@ permissions: contents: read jobs: distribute-spring-enterprise-release-bundle: + name: Distribute Release Bundle ðŸ“Ķ runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Create Bundle diff --git a/.github/workflows/release-milestone.yml b/.github/workflows/release-milestone.yml index 6a46387389bf..13dde6689c6e 100644 --- a/.github/workflows/release-milestone.yml +++ b/.github/workflows/release-milestone.yml @@ -14,9 +14,9 @@ jobs: if: ${{ github.repository == 'spring-projects/spring-boot' }} runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - - name: Build and Publish + - name: Build ðŸ“Ķ and Publish ðŸ“Ą id: build-and-publish uses: ./.github/actions/build with: @@ -59,7 +59,7 @@ jobs: - verify runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Sync to Maven Central uses: ./.github/actions/sync-to-maven-central @@ -89,7 +89,7 @@ jobs: - sync-to-maven-central runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Publish uses: ./.github/actions/publish-gradle-plugin @@ -120,7 +120,7 @@ jobs: - trigger-docs-build runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Create GitHub Release uses: ./.github/actions/create-github-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2529ebe8cca1..07339a3cf4d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,9 @@ jobs: if: ${{ github.repository == 'spring-projects/spring-boot' || github.repository == 'spring-projects/spring-boot-commercial' }} runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - - name: Build and Publish + - name: Build ðŸ“Ķ and Publish ðŸ“Ą id: build-and-publish uses: ./.github/actions/build with: @@ -70,7 +70,7 @@ jobs: - verify runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Sync to Maven Central uses: ./.github/actions/sync-to-maven-central @@ -104,7 +104,7 @@ jobs: - sync-to-maven-central runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Publish uses: ./.github/actions/publish-gradle-plugin @@ -121,7 +121,7 @@ jobs: - sync-to-maven-central runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Publish to SDKMAN! uses: ./.github/actions/publish-to-sdkman @@ -137,7 +137,7 @@ jobs: - sync-to-maven-central runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Update Homebrew Tap uses: ./.github/actions/update-homebrew-tap @@ -168,7 +168,7 @@ jobs: - update-homebrew-tap runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Create GitHub Release uses: ./.github/actions/create-github-release diff --git a/.github/workflows/run-codeql-analysis.yml b/.github/workflows/run-codeql-analysis.yml index f3a9f268e463..5c2642de0f8b 100644 --- a/.github/workflows/run-codeql-analysis.yml +++ b/.github/workflows/run-codeql-analysis.yml @@ -1,4 +1,4 @@ -name: "Run CodeQL Analysis" +name: Run CodeQL Analysis 📊 on: push: pull_request: @@ -6,6 +6,7 @@ on: permissions: read-all jobs: run-analysis: + name: Inspect 🔎 permissions: actions: read contents: read diff --git a/.github/workflows/run-system-tests.yml b/.github/workflows/run-system-tests.yml index 9dcf62d7f318..bb0701f2c8cf 100644 --- a/.github/workflows/run-system-tests.yml +++ b/.github/workflows/run-system-tests.yml @@ -18,7 +18,7 @@ jobs: - version: 21 toolchain: true steps: - - name: Check Out Code + - name: Checkout Code ðŸ“Ĩ uses: actions/checkout@v6 - name: Prepare Gradle Build uses: ./.github/actions/prepare-gradle-build diff --git a/build.gradle b/build.gradle index 84acc8603902..b8dde8dd92f3 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ plugins { id "base" + id "org.openrewrite.rewrite" version "7.23.0" apply false } description = "Spring Boot Build" @@ -46,3 +47,5 @@ subprojects { resolutionStrategy.cacheChangingModulesFor 0, "minutes" } } + +apply from: rootProject.file("gradle/plugins/config/sanity.gradle") diff --git a/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Cache.java b/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Cache.java index a3e4f98a815b..6899b7160cfe 100644 --- a/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Cache.java +++ b/buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Cache.java @@ -70,7 +70,7 @@ public String getDescription() { * @return the cache, or {@code null} if it is not a volume cache */ public @Nullable Volume getVolume() { - return (this.format.equals(Format.VOLUME)) ? (Volume) this : null; + return (this.format == Format.VOLUME) ? (Volume) this : null; } /** @@ -78,7 +78,7 @@ public String getDescription() { * @return the cache, or {@code null} if it is not a bind cache */ public @Nullable Bind getBind() { - return (this.format.equals(Format.BIND)) ? (Bind) this : null; + return (this.format == Format.BIND) ? (Bind) this : null; } /** @@ -120,7 +120,7 @@ public boolean equals(@Nullable Object obj) { return false; } Cache other = (Cache) obj; - return Objects.equals(this.format, other.format); + return this.format == other.format; } @Override diff --git a/cli/spring-boot-cli/src/test/resources/commands/command.groovy b/cli/spring-boot-cli/src/test/resources/commands/command.groovy index 3877109c7e14..c2039b13ae7f 100644 --- a/cli/spring-boot-cli/src/test/resources/commands/command.groovy +++ b/cli/spring-boot-cli/src/test/resources/commands/command.groovy @@ -25,9 +25,9 @@ class TestCommand implements Command { String help = "No options" String usageHelp = "Not very useful" - + Collection optionsHelp = ["No options"] - + boolean optionCommand = false void run(String... args) { diff --git a/cli/spring-boot-cli/src/test/resources/dir-sample/code/app.groovy b/cli/spring-boot-cli/src/test/resources/dir-sample/code/app.groovy index f273c49434a4..57140ab20062 100644 --- a/cli/spring-boot-cli/src/test/resources/dir-sample/code/app.groovy +++ b/cli/spring-boot-cli/src/test/resources/dir-sample/code/app.groovy @@ -7,7 +7,7 @@ class Example implements CommandLineRunner { private MyService myService void run(String... args) { - println "Hello ${this.myService.sayWorld()} From ${getClass().getClassLoader().getResource('samples/app.groovy')}" + println "Hello ${this.myService.sayWorld()} From ${getClass().getClassLoader().getResource('samples/app.groovy')}" } } diff --git a/cli/spring-boot-cli/src/test/resources/scripts/closure.groovy b/cli/spring-boot-cli/src/test/resources/scripts/closure.groovy index 490320c38daa..d52b66803fad 100644 --- a/cli/spring-boot-cli/src/test/resources/scripts/closure.groovy +++ b/cli/spring-boot-cli/src/test/resources/scripts/closure.groovy @@ -17,7 +17,7 @@ def foo() { "Foo" } - + command("foo") { options -> def foo = foo() println "Hello ${foo} ${options.nonOptionArguments()}: ${options.has('foo')} ${options.valueOf('bar')}" diff --git a/cli/spring-boot-cli/src/test/resources/scripts/command.groovy b/cli/spring-boot-cli/src/test/resources/scripts/command.groovy index 3479910984f3..180961de612f 100644 --- a/cli/spring-boot-cli/src/test/resources/scripts/command.groovy +++ b/cli/spring-boot-cli/src/test/resources/scripts/command.groovy @@ -27,9 +27,9 @@ class TestCommand implements Command { String help = "No options" String usageHelp = "Not very useful" - + Collection optionsHelp = ["No options"] - + boolean optionCommand = false void run(String... args) { diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java index a856c2801613..1f178884a89b 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/system/OutputCapture.java @@ -122,7 +122,7 @@ public String getAll() { */ @Override public String getOut() { - return get(this.out, Type.OUT::equals); + return get(this.out, (v) -> v == Type.OUT); } /** @@ -131,7 +131,7 @@ public String getOut() { */ @Override public String getErr() { - return get(this.err, Type.ERR::equals); + return get(this.err, (v) -> v == Type.ERR); } /** diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 190b05ffb311..2b54d4a4565f 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -211,7 +211,7 @@ private void addToSources(MutablePropertySources sources, Type type, String name } } Map source = new LinkedHashMap<>(this.properties); - sources.addFirst((type.equals(Type.MAP) ? new MapPropertySource(name, source) + sources.addFirst(((type == Type.MAP) ? new MapPropertySource(name, source) : new SystemEnvironmentPropertySource(name, source))); } diff --git a/gradle/plugins/config/sanity.gradle b/gradle/plugins/config/sanity.gradle new file mode 100644 index 000000000000..34a6b584844d --- /dev/null +++ b/gradle/plugins/config/sanity.gradle @@ -0,0 +1,14 @@ +project.apply(plugin: "org.openrewrite.rewrite") +dependencies { + rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.24.0") + rewrite("org.openrewrite.recipe:rewrite-third-party:0.32.1") +} +repositories { + mavenCentral() +} +rewrite { + activeRecipe("org.springframework.boot.openrewrite.SanityCheck") + configFile = project.getRootProject().file("${rootDir}/gradle/plugins/config/sanity.yml") + setExportDatatables(true) + setFailOnDryRunResults(true) +} diff --git a/gradle/plugins/config/sanity.yml b/gradle/plugins/config/sanity.yml new file mode 100644 index 000000000000..551c3a13ab36 --- /dev/null +++ b/gradle/plugins/config/sanity.yml @@ -0,0 +1,53 @@ +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.springframework.boot.openrewrite.SanityCheck # 7m 52s +displayName: Apply all common best practices +description: Comprehensive code quality recipe combining modernization, security, and best practices. +recipeList: + - org.openrewrite.java.format.NormalizeFormat + - org.openrewrite.java.format.NormalizeLineBreaks + - org.openrewrite.java.format.RemoveTrailingWhitespace + - org.openrewrite.staticanalysis.ModifierOrder + - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables + - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields + - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods + - org.openrewrite.staticanalysis.ReplaceLambdaWithMethodReference + - org.openrewrite.staticanalysis.SimplifyTernaryRecipes + - org.openrewrite.staticanalysis.UnnecessaryCloseInTryWithResources + - org.openrewrite.staticanalysis.UnnecessaryExplicitTypeArguments + - org.openrewrite.staticanalysis.UnnecessaryReturnAsLastStatement + - tech.picnic.errorprone.refasterrules.EqualityRulesRecipes +# - org.openrewrite.java.migrate.UpgradeToJava17 +# - org.openrewrite.java.recipes.JavaRecipeBestPractices +# - org.openrewrite.java.recipes.RecipeTestingBestPractices +# - org.openrewrite.java.testing.junit.JupiterBestPractices +# - org.openrewrite.java.testing.junit5.CleanupAssertions +# - org.openrewrite.java.testing.junit5.StaticImports +# - org.openrewrite.maven.BestPractices +# - org.openrewrite.recipes.rewrite.OpenRewriteRecipeBestPractices +# - org.openrewrite.staticanalysis.BufferedWriterCreationRecipes +# - org.openrewrite.staticanalysis.EqualsAvoidsNull # 60 changes +# - org.openrewrite.staticanalysis.InlineVariable +# - org.openrewrite.staticanalysis.JavaApiBestPractices +# - org.openrewrite.staticanalysis.LowercasePackage +# - org.openrewrite.staticanalysis.NoFinalizer +# - org.openrewrite.staticanalysis.NoToStringOnStringType +# - org.openrewrite.staticanalysis.URLEqualsHashCodeRecipes +# - org.openrewrite.staticanalysis.UnnecessaryParentheses # 2k changes +# - tech.picnic.errorprone.refasterrules.BigDecimalRulesRecipes +# - tech.picnic.errorprone.refasterrules.CharSequenceRulesRecipes +# - tech.picnic.errorprone.refasterrules.ClassRulesRecipes +# - tech.picnic.errorprone.refasterrules.CollectionRulesRecipes +# - tech.picnic.errorprone.refasterrules.ComparatorRulesRecipes +# - tech.picnic.errorprone.refasterrules.FileRulesRecipes +# - tech.picnic.errorprone.refasterrules.MapRulesRecipes +# - tech.picnic.errorprone.refasterrules.MicrometerRulesRecipes +# - tech.picnic.errorprone.refasterrules.MockitoRulesRecipes +# - tech.picnic.errorprone.refasterrules.NullRulesRecipes +# - tech.picnic.errorprone.refasterrules.PatternRulesRecipes +# - tech.picnic.errorprone.refasterrules.PreconditionsRulesRecipes +# - tech.picnic.errorprone.refasterrules.PrimitiveRulesRecipes +# - tech.picnic.errorprone.refasterrules.StreamRulesRecipes +# - tech.picnic.errorprone.refasterrules.StringRulesRecipes +# - tech.picnic.errorprone.refasterrules.TimeRulesRecipes +--- diff --git a/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java b/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java index 975ab67d56dd..d02433bf44d7 100644 --- a/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java +++ b/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java @@ -217,7 +217,7 @@ public boolean equals(Object obj) { return false; } CacheKey other = (CacheKey) obj; - return this.apiVersion.equals(other.apiVersion) + return this.apiVersion == other.apiVersion && ObjectUtils.nullSafeEquals(this.principal, other.principal) && ObjectUtils.nullSafeEquals(this.serverNamespace, other.serverNamespace); } diff --git a/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoPropertiesInfoContributor.java b/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoPropertiesInfoContributor.java index 3cd1d7276811..5cba6f55de38 100644 --- a/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoPropertiesInfoContributor.java +++ b/module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoPropertiesInfoContributor.java @@ -123,7 +123,7 @@ protected void postProcessContent(Map content) { * @return the property source */ protected PropertySource toPropertySource() { - if (this.mode.equals(Mode.FULL)) { + if (this.mode == Mode.FULL) { return this.properties.toPropertySource(); } return toSimplePropertySource(); diff --git a/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java b/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java index aa83ab889331..6102f7aa8937 100644 --- a/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java +++ b/module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java @@ -92,7 +92,7 @@ public boolean equals(@Nullable Object obj) { return false; } if (obj instanceof ChangedFile other) { - return this.file.equals(other.file) && this.type.equals(other.type); + return this.file.equals(other.file) && this.type == other.type; } return super.equals(obj); } diff --git a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MainMethodTests.java b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MainMethodTests.java index cc7a328c378b..d9108e67c7ca 100644 --- a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MainMethodTests.java +++ b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MainMethodTests.java @@ -62,7 +62,7 @@ void nestedMainMethod() throws Exception { @Test // gh-39733 void viaJarLauncher() throws Exception { - FakeJarLauncher.action = (args) -> Valid.main(args); + FakeJarLauncher.action = MainMethodTests.Valid::main; MainMethod method = new TestThread(FakeJarLauncher::main).test(); Method expectedMain = Valid.class.getMethod("main", String[].class); assertThat(method.getMethod()).isEqualTo(expectedMain); diff --git a/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizer.java b/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizer.java index 8088cd354811..270af7b05920 100644 --- a/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizer.java +++ b/module/spring-boot-jetty/src/main/java/org/springframework/boot/jetty/autoconfigure/JettyWebServerFactoryCustomizer.java @@ -205,7 +205,7 @@ private String getLogFormat(JettyServerProperties.Accesslog properties) { if (properties.getCustomFormat() != null) { return properties.getCustomFormat(); } - if (Accesslog.Format.EXTENDED_NCSA.equals(properties.getFormat())) { + if (Accesslog.Format.EXTENDED_NCSA == properties.getFormat()) { return CustomRequestLog.EXTENDED_NCSA_FORMAT; } return CustomRequestLog.NCSA_FORMAT; diff --git a/module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/ConcurrentKafkaListenerContainerFactoryConfigurer.java b/module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/ConcurrentKafkaListenerContainerFactoryConfigurer.java index 12b8c1ccbd1e..3fbb04615fb3 100644 --- a/module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/ConcurrentKafkaListenerContainerFactoryConfigurer.java +++ b/module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/ConcurrentKafkaListenerContainerFactoryConfigurer.java @@ -210,7 +210,7 @@ private void configureListenerFactory(ConcurrentKafkaListenerContainerFactory getType() { private > Function present() { return (contextRunner) -> (T) contextRunner .withClassLoader(new FilteredClassLoader(Stream.of(AlternativeFormOfAuthentication.values()) - .filter(Predicate.not(this::equals)) + .filter(Predicate.not((v) -> v == this)) .map(AlternativeFormOfAuthentication::getType) .toArray(Class[]::new))); } diff --git a/module/spring-boot-sql/src/main/java/org/springframework/boot/sql/autoconfigure/init/OnDatabaseInitializationCondition.java b/module/spring-boot-sql/src/main/java/org/springframework/boot/sql/autoconfigure/init/OnDatabaseInitializationCondition.java index 766f00c28ff3..63a1f85bf346 100644 --- a/module/spring-boot-sql/src/main/java/org/springframework/boot/sql/autoconfigure/init/OnDatabaseInitializationCondition.java +++ b/module/spring-boot-sql/src/main/java/org/springframework/boot/sql/autoconfigure/init/OnDatabaseInitializationCondition.java @@ -67,7 +67,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM } private boolean match(DatabaseInitializationMode mode) { - return !mode.equals(DatabaseInitializationMode.NEVER); + return mode != DatabaseInitializationMode.NEVER; } private DatabaseInitializationMode getDatabaseInitializationMode(Environment environment, diff --git a/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/servlet/TomcatServletWebServerFactoryTests.java b/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/servlet/TomcatServletWebServerFactoryTests.java index f9362d661aa6..ff8442f29d71 100644 --- a/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/servlet/TomcatServletWebServerFactoryTests.java +++ b/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/servlet/TomcatServletWebServerFactoryTests.java @@ -632,7 +632,7 @@ void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() throws E }); Object unconnectableRequest = Awaitility.await() .until(() -> initiateGetRequest(HttpClients.createDefault(), port, "/").get(), - (result) -> result instanceof Exception); + Exception.class::isInstance); assertThat(unconnectableRequest).isInstanceOf(HttpHostConnectException.class); blockingServlet.admitOne(); assertThat(request.get()).isInstanceOf(HttpResponse.class); @@ -664,7 +664,7 @@ void whenServerIsShuttingDownARequestOnAnIdleConnectionResultsInConnectionReset( Future idleConnectionRequest = initiateGetRequest(httpClient, port, "/"); Object result = idleConnectionRequest.get(); return result; - }, (result) -> result instanceof Exception); + }, Exception.class::isInstance); assertThat(idleConnectionRequestResult).isInstanceOfAny(SocketException.class, NoHttpResponseException.class); if (idleConnectionRequestResult instanceof SocketException socketException) { assertThat(socketException).hasMessage("Connection reset"); diff --git a/module/spring-boot-zipkin/src/main/java/org/springframework/boot/zipkin/autoconfigure/ZipkinHttpClientSender.java b/module/spring-boot-zipkin/src/main/java/org/springframework/boot/zipkin/autoconfigure/ZipkinHttpClientSender.java index 7a62e859895c..d1adba9fd4b5 100644 --- a/module/spring-boot-zipkin/src/main/java/org/springframework/boot/zipkin/autoconfigure/ZipkinHttpClientSender.java +++ b/module/spring-boot-zipkin/src/main/java/org/springframework/boot/zipkin/autoconfigure/ZipkinHttpClientSender.java @@ -54,7 +54,7 @@ void postSpans(URI endpoint, Map headers, byte[] body) throws IO .POST(BodyPublishers.ofByteArray(body)) .uri(endpoint) .timeout(this.readTimeout); - headers.forEach((name, value) -> request.header(name, value)); + headers.forEach(request::header); try { HttpResponse response = this.httpClient.send(request.build(), BodyHandlers.discarding()); if (response.statusCode() / 100 != 2) { diff --git a/test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/system/OutputCapture.java b/test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/system/OutputCapture.java index a152b855fa95..27291e4339a3 100644 --- a/test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/system/OutputCapture.java +++ b/test-support/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/system/OutputCapture.java @@ -91,7 +91,7 @@ public String getAll() { */ @Override public String getOut() { - return get(Type.OUT::equals); + return get((v) -> v == Type.OUT); } /** @@ -100,7 +100,7 @@ public String getOut() { */ @Override public String getErr() { - return get(Type.ERR::equals); + return get((v) -> v == Type.ERR); } /**