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/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 { 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