From 83a5047062d097e8e2a48242c1bd8d15ce7105ae Mon Sep 17 00:00:00 2001 From: Pavel Vassiliev Date: Sun, 11 Jan 2026 19:08:13 -0500 Subject: [PATCH 1/3] Fix spring-security-oauth2-core compiler warnings Closes: gh-18434 Signed-off-by: Pavel Vassiliev Signed-off-by: paulvas --- .../function/OAuth2BodyExtractorsTests.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java index 79c573d28fd..6b33eee6622 100644 --- a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java +++ b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/web/reactive/function/OAuth2BodyExtractorsTests.java @@ -17,7 +17,6 @@ package org.springframework.security.oauth2.core.web.reactive.function; import java.time.Instant; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -27,15 +26,11 @@ import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; -import org.springframework.core.codec.ByteBufferDecoder; -import org.springframework.core.codec.StringDecoder; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpInputMessage; -import org.springframework.http.codec.DecoderHttpMessageReader; -import org.springframework.http.codec.FormHttpMessageReader; +import org.springframework.http.codec.ClientCodecConfigurer; import org.springframework.http.codec.HttpMessageReader; -import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.mock.http.client.reactive.MockClientHttpResponse; import org.springframework.security.oauth2.core.OAuth2AccessToken; @@ -58,11 +53,7 @@ public class OAuth2BodyExtractorsTests { @BeforeEach public void createContext() { - final List> messageReaders = new ArrayList<>(); - messageReaders.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder())); - messageReaders.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes())); - messageReaders.add(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder())); - messageReaders.add(new FormHttpMessageReader()); + List> messageReaders = ClientCodecConfigurer.create().getReaders(); this.hints = new HashMap<>(); this.context = new BodyExtractor.Context() { @Override From c6950bc1a2fd9c3581cb319a656af7bf77166b2e Mon Sep 17 00:00:00 2001 From: paulvas Date: Mon, 12 Jan 2026 12:58:59 -0500 Subject: [PATCH 2/3] Fix: Enforce compiler warnings in oauth2-core To prevent future compiler warnings from being introduced, this change applies the `compile-warnings-error` plugin to the `spring-security-oauth2-core` module. This ensures that any new warnings will fail the build, maintaining code quality and preventing warning accumulation. Fixes: gh-18434 Signed-off-by: Pavel Vassiliev Signed-off-by: paulvas --- buildSrc/build.gradle | 4 ++++ .../src/main/groovy/compile-warnings-error.groovy | 15 +++++++++++++++ .../spring-security-oauth2-core.gradle | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 buildSrc/src/main/groovy/compile-warnings-error.groovy diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 87b5fcd62f5..ca5f95959bf 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -52,6 +52,10 @@ gradlePlugin { id = "org.springframework.security.check-expected-branch-version" implementationClass = "org.springframework.security.CheckExpectedBranchVersionPlugin" } + compileWarningsError { + id = "compile-warnings-error" + implementationClass = "CompileWarningsErrorPlugin" + } } } diff --git a/buildSrc/src/main/groovy/compile-warnings-error.groovy b/buildSrc/src/main/groovy/compile-warnings-error.groovy new file mode 100644 index 00000000000..f2d073de3c8 --- /dev/null +++ b/buildSrc/src/main/groovy/compile-warnings-error.groovy @@ -0,0 +1,15 @@ +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.compile.JavaCompile +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class CompileWarningsErrorPlugin implements Plugin { + void apply(Project project) { + project.tasks.withType(JavaCompile) { + options.compilerArgs += "-Werror" + } + project.tasks.withType(KotlinCompile) { + kotlinOptions.allWarningsAsErrors = true + } + } +} \ No newline at end of file diff --git a/oauth2/oauth2-core/spring-security-oauth2-core.gradle b/oauth2/oauth2-core/spring-security-oauth2-core.gradle index c163adfcca7..a3c3a2f4e9a 100644 --- a/oauth2/oauth2-core/spring-security-oauth2-core.gradle +++ b/oauth2/oauth2-core/spring-security-oauth2-core.gradle @@ -1,3 +1,7 @@ +plugins { + id 'compile-warnings-error' +} + apply plugin: 'io.spring.convention.spring-module' dependencies { From e751d14db63b37fef84d8834f569e6dadc35614f Mon Sep 17 00:00:00 2001 From: paulvas Date: Mon, 12 Jan 2026 14:46:26 -0500 Subject: [PATCH 3/3] Fix: migrate compiler-warnings-error plugin to gradle Fixes: gh-18434 Signed-off-by: paulvas --- buildSrc/build.gradle | 4 ---- .../src/main/groovy/compile-warnings-error.gradle | 10 ++++++++++ .../src/main/groovy/compile-warnings-error.groovy | 15 --------------- 3 files changed, 10 insertions(+), 19 deletions(-) create mode 100644 buildSrc/src/main/groovy/compile-warnings-error.gradle delete mode 100644 buildSrc/src/main/groovy/compile-warnings-error.groovy diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index ca5f95959bf..87b5fcd62f5 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -52,10 +52,6 @@ gradlePlugin { id = "org.springframework.security.check-expected-branch-version" implementationClass = "org.springframework.security.CheckExpectedBranchVersionPlugin" } - compileWarningsError { - id = "compile-warnings-error" - implementationClass = "CompileWarningsErrorPlugin" - } } } diff --git a/buildSrc/src/main/groovy/compile-warnings-error.gradle b/buildSrc/src/main/groovy/compile-warnings-error.gradle new file mode 100644 index 00000000000..4c23ae9f93b --- /dev/null +++ b/buildSrc/src/main/groovy/compile-warnings-error.gradle @@ -0,0 +1,10 @@ +import org.gradle.api.tasks.compile.JavaCompile +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +tasks.withType(JavaCompile) { + options.compilerArgs += "-Werror" +} + +tasks.withType(KotlinCompile) { + kotlinOptions.allWarningsAsErrors = true +} diff --git a/buildSrc/src/main/groovy/compile-warnings-error.groovy b/buildSrc/src/main/groovy/compile-warnings-error.groovy deleted file mode 100644 index f2d073de3c8..00000000000 --- a/buildSrc/src/main/groovy/compile-warnings-error.groovy +++ /dev/null @@ -1,15 +0,0 @@ -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.tasks.compile.JavaCompile -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -class CompileWarningsErrorPlugin implements Plugin { - void apply(Project project) { - project.tasks.withType(JavaCompile) { - options.compilerArgs += "-Werror" - } - project.tasks.withType(KotlinCompile) { - kotlinOptions.allWarningsAsErrors = true - } - } -} \ No newline at end of file