From 3910a578a64092d18adde9c8e880c9d7aeb04c97 Mon Sep 17 00:00:00 2001 From: Pierre De Rop Date: Tue, 28 Mar 2023 20:01:53 +0200 Subject: [PATCH] Adapt to Netty5 SLF4J changes (#2749) Adaptations made for the Netty5 SLF4J netty/netty#13285 PR. socks-proxy and codec-multipart netty contrib projects have also been updated, because io.netty5.util.internal.logging.InternalLoggerFactory is not supported anymore. --- .github/workflows/check_transport.yml | 96 ++++++++++--------- .github/workflows/codeql-analysis.yml | 4 +- build.gradle | 7 +- reactor-netty5-core/build.gradle | 2 +- .../transport/NameResolverProvider.java | 6 +- .../transport/NameResolverProviderTest.java | 4 +- reactor-netty5-examples/build.gradle | 4 +- reactor-netty5-http/build.gradle | 9 +- .../netty5/http/client/HttpClientConfig.java | 5 +- .../netty5/http/server/HttpServerConfig.java | 5 +- .../netty5/http/client/HttpClientTest.java | 3 +- 11 files changed, 79 insertions(+), 66 deletions(-) diff --git a/.github/workflows/check_transport.yml b/.github/workflows/check_transport.yml index 1f2e31d560..1c5f654575 100644 --- a/.github/workflows/check_transport.yml +++ b/.github/workflows/check_transport.yml @@ -4,41 +4,41 @@ on: pull_request: {} permissions: read-all jobs: - preliminary: - name: preliminary sanity checks - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 #needed by spotless - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - name: spotless (license header) - if: always() - run: ./gradlew clean spotlessCheck -PspotlessFrom=origin/${{ github.base_ref }} - - name: api compatibility - if: always() - run: ./gradlew clean japicmp - - name: how to fix - if: failure() +# preliminary: +# name: preliminary sanity checks +# runs-on: ubuntu-20.04 +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 #needed by spotless +# - uses: actions/setup-java@v3 +# with: +# distribution: 'temurin' +# java-version: 17 +# - name: spotless (license header) +# if: always() +# run: ./gradlew clean spotlessCheck -PspotlessFrom=origin/${{ github.base_ref }} +# - name: api compatibility +# if: always() +# run: ./gradlew clean japicmp +# - name: how to fix +# if: failure() # the foreground (38;5) color code 208 is orange. we also have bold, white bg (38;5;0;48;5;255m), white fg on black bg... - run: | - echo -e "\n\033[38;5;0;48;5;208m \u001b[1m How to deal with errors in preliminary job: \u001b[0m\033[0m" - echo "(Have a look at the steps above to see what failed exactly)" - echo -e "\n - \u001b[1mSpotless (license headers)\u001b[0m failures on touched java files \033[38;5;255;48;5;0m\u001b[1mcan be automatically fixed by running\u001b[0m:" - echo -e " \033[38;5;0;48;5;255m ./gradlew spotlessApply \033[0m" - echo -e "\n - \u001b[1mAPI Compatibility\u001b[0m failures should be considered carefully and \033[38;5;255;48;5;0m\u001b[1mdiscussed with maintainers in the PR\u001b[0m" - echo " If there are failures, the detail should be available in the step's log:" - echo -e " Look for the \033[38;5;0;48;5;255m API compatibility failures \033[0m block(s)." - echo " Alternatively, locally run the following command to get access to the full report:" - echo -e " \033[38;5;0;48;5;255m ./gradlew japicmp \033[0m" - echo "" - exit -1 +# run: | +# echo -e "\n\033[38;5;0;48;5;208m \u001b[1m How to deal with errors in preliminary job: \u001b[0m\033[0m" +# echo "(Have a look at the steps above to see what failed exactly)" +# echo -e "\n - \u001b[1mSpotless (license headers)\u001b[0m failures on touched java files \033[38;5;255;48;5;0m\u001b[1mcan be automatically fixed by running\u001b[0m:" +# echo -e " \033[38;5;0;48;5;255m ./gradlew spotlessApply \033[0m" +# echo -e "\n - \u001b[1mAPI Compatibility\u001b[0m failures should be considered carefully and \033[38;5;255;48;5;0m\u001b[1mdiscussed with maintainers in the PR\u001b[0m" +# echo " If there are failures, the detail should be available in the step's log:" +# echo -e " Look for the \033[38;5;0;48;5;255m API compatibility failures \033[0m block(s)." +# echo " Alternatively, locally run the following command to get access to the full report:" +# echo -e " \033[38;5;0;48;5;255m ./gradlew japicmp \033[0m" +# echo "" +# exit -1 build: - needs: preliminary +# needs: preliminary runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -54,9 +54,9 @@ jobs: transport: native steps: - uses: actions/checkout@v3 -# with: -# path: reactor-netty -# fetch-depth: 0 #needed by spotless + with: + path: reactor-netty + fetch-depth: 0 #needed by spotless # - uses: actions/checkout@v3 # with: # repository: netty-contrib/codec-haproxy @@ -65,10 +65,14 @@ jobs: # with: # repository: netty-contrib/codec-extras # path: codec-extras -# - uses: actions/checkout@v3 -# with: -# repository: netty-contrib/socks-proxy -# path: socks-proxy + - uses: actions/checkout@v3 + with: + repository: netty-contrib/socks-proxy + path: socks-proxy + - uses: actions/checkout@v3 + with: + repository: netty-contrib/codec-multipart + path: codec-multipart - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 17 uses: actions/setup-java@v3 @@ -81,9 +85,13 @@ jobs: # - name: Build codec-extras # run: ./mvnw install -DskipTests=true "-Dnetty.version=5.0.0.Alpha5" # working-directory: ./codec-extras -# - name: Build socks-proxy -# run: ./mvnw install -DskipTests=true "-Dnetty.version=5.0.0.Alpha5" -# working-directory: ./socks-proxy + - name: Build socks-proxy + run: ./mvnw install -DskipTests=true "-Dnetty.version=5.0.0.Alpha6-SNAPSHOT" + working-directory: ./socks-proxy + - name: Build codec-multipart + run: ./mvnw install -DskipTests=true "-Dnetty.version=5.0.0.Alpha6-SNAPSHOT" + working-directory: ./codec-multipart - name: Build with Gradle - run: ./gradlew clean check --no-daemon -PforceTransport=${{ matrix.transport }} -x spotlessCheck -# working-directory: ./reactor-netty \ No newline at end of file +# run: ./gradlew clean check --no-daemon -PforceTransport=${{ matrix.transport }} -x spotlessCheck + run: ./gradlew clean check --no-daemon -PforceTransport=${{ matrix.transport }} -PspotlessFrom=origin/netty5 + working-directory: ./reactor-netty \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7a3b456e2d..4d6e8e2c07 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,13 +10,13 @@ on: branches: - main - 1.0.x - - netty5 +# - netty5 pull_request: # The branches below must be a subset of the branches above branches: - main - 1.0.x - - netty5 +# - netty5 schedule: - cron: '0 12 * * 6' permissions: read-all diff --git a/build.gradle b/build.gradle index e05911fe9a..8ed401632b 100644 --- a/build.gradle +++ b/build.gradle @@ -97,8 +97,8 @@ ext { jsr305Version = '3.0.2' // Logging - slf4jVersion = '1.7.36' - logbackVersion = '1.2.12' + slf4jVersion = '2.0.7' + logbackVersion = '1.4.6' // Netty nettyDefaultVersion = '5.0.0.Alpha6-SNAPSHOT' @@ -111,7 +111,8 @@ ext { } nettyContribVersion = '5.0.0.Alpha2' //nettyQuicVersion = '0.0.38.Final' - nettyContribMultipartVersion = '5.0.0.Alpha1' + nettyContribMultipartVersion = '5.0.0.Alpha2-SNAPSHOT' + nettyContribHandlerProxyVersion = '5.0.0.Alpha3-SNAPSHOT' // Testing jacksonDatabindVersion = '2.14.2' diff --git a/reactor-netty5-core/build.gradle b/reactor-netty5-core/build.gradle index 655ce28986..d18be2acce 100644 --- a/reactor-netty5-core/build.gradle +++ b/reactor-netty5-core/build.gradle @@ -58,7 +58,7 @@ dependencies { compileOnly "com.google.code.findbugs:jsr305:$jsr305Version" api "io.netty:netty5-handler:$nettyVersion" - api("io.netty.contrib:netty-handler-proxy:$nettyContribVersion") { + api("io.netty.contrib:netty-handler-proxy:$nettyContribHandlerProxyVersion") { exclude module: "netty5-codec-http" } api "io.netty:netty5-resolver-dns:$nettyVersion" diff --git a/reactor-netty5-core/src/main/java/reactor/netty5/transport/NameResolverProvider.java b/reactor-netty5-core/src/main/java/reactor/netty5/transport/NameResolverProvider.java index 2cc5cadc14..489f6e1897 100644 --- a/reactor-netty5-core/src/main/java/reactor/netty5/transport/NameResolverProvider.java +++ b/reactor-netty5-core/src/main/java/reactor/netty5/transport/NameResolverProvider.java @@ -18,7 +18,6 @@ import io.netty5.channel.EventLoopGroup; import io.netty5.channel.socket.DatagramChannel; import io.netty5.channel.socket.SocketChannel; -import io.netty5.handler.logging.LogLevel; import io.netty5.resolver.AddressResolverGroup; import io.netty5.resolver.DefaultHostsFileEntriesResolver; import io.netty5.resolver.HostsFileEntriesResolver; @@ -31,6 +30,7 @@ import io.netty5.resolver.dns.LoggingDnsQueryLifeCycleObserverFactory; import io.netty5.resolver.dns.RoundRobinDnsAddressResolverGroup; import io.netty5.util.concurrent.Future; +import org.slf4j.event.Level; import reactor.netty5.resources.LoopResources; import reactor.util.annotation.Nullable; @@ -256,7 +256,7 @@ public interface NameResolverSpec { * @param level the logger level * @return {@code this} */ - NameResolverSpec trace(String category, LogLevel level); + NameResolverSpec trace(String category, Level level); } /** @@ -749,7 +749,7 @@ public NameResolverSpec searchDomains(List searchDomains) { } @Override - public NameResolverSpec trace(String category, LogLevel level) { + public NameResolverSpec trace(String category, Level level) { Objects.requireNonNull(category, "category"); Objects.requireNonNull(level, "level"); this.loggingFactory = new LoggingDnsQueryLifeCycleObserverFactory(category, level); diff --git a/reactor-netty5-core/src/test/java/reactor/netty5/transport/NameResolverProviderTest.java b/reactor-netty5-core/src/test/java/reactor/netty5/transport/NameResolverProviderTest.java index 026d71b4e7..f9fdc75d60 100644 --- a/reactor-netty5-core/src/test/java/reactor/netty5/transport/NameResolverProviderTest.java +++ b/reactor-netty5-core/src/test/java/reactor/netty5/transport/NameResolverProviderTest.java @@ -17,7 +17,6 @@ import io.netty5.channel.EventLoop; import io.netty5.handler.codec.dns.DnsRecord; -import io.netty5.handler.logging.LogLevel; import io.netty5.resolver.ResolvedAddressTypes; import io.netty5.resolver.dns.DnsCache; import io.netty5.resolver.dns.DnsCacheEntry; @@ -27,6 +26,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; +import org.slf4j.event.Level; import reactor.netty5.resources.LoopResources; import reactor.netty5.tcp.TcpResources; @@ -301,7 +301,7 @@ void searchDomainsBadValues() { @Test void traceBadValues() { assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> builder.trace(null, LogLevel.DEBUG)); + .isThrownBy(() -> builder.trace(null, Level.DEBUG)); assertThatExceptionOfType(NullPointerException.class) .isThrownBy(() -> builder.trace("category", null)); diff --git a/reactor-netty5-examples/build.gradle b/reactor-netty5-examples/build.gradle index bbd2bde211..5b958fbdf0 100644 --- a/reactor-netty5-examples/build.gradle +++ b/reactor-netty5-examples/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2023 VMware, Inc. or its affiliates, 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. @@ -29,7 +29,7 @@ dependencies { runtimeOnly "ch.qos.logback:logback-classic:$logbackVersion" runtimeOnly "io.netty:netty-tcnative-boringssl-static:$boringSslVersion$os_suffix" // Needed for proxy testing - runtimeOnly "io.netty.contrib:netty-handler-proxy:$nettyContribVersion" + runtimeOnly "io.netty.contrib:netty-handler-proxy:$nettyContribHandlerProxyVersion" } description = "Examples for the Reactor Netty library" \ No newline at end of file diff --git a/reactor-netty5-http/build.gradle b/reactor-netty5-http/build.gradle index 4ced7fbf3a..f004318a65 100644 --- a/reactor-netty5-http/build.gradle +++ b/reactor-netty5-http/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2023 VMware, Inc. or its affiliates, 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. @@ -64,7 +64,7 @@ dependencies { // JSR-305 annotations compileOnly "com.google.code.findbugs:jsr305:$jsr305Version" - api "io.netty.contrib:netty-handler-proxy:$nettyContribVersion" + api "io.netty.contrib:netty-handler-proxy:$nettyContribHandlerProxyVersion" api "io.netty:netty5-codec-http:$nettyVersion" api "io.netty:netty5-codec-http2:$nettyVersion" api "io.netty:netty5-resolver-dns:$nettyVersion" @@ -148,6 +148,7 @@ dependencies { } testImplementation "io.netty.contrib:netty-codec-extras:$nettyContribVersion" testImplementation "org.reflections:reflections:$reflectionsVersion" + testImplementation "org.slf4j:slf4j-api:$slf4jVersion" testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" @@ -155,7 +156,7 @@ dependencies { testRuntimeOnly "ch.qos.logback:logback-classic:$logbackVersion" // Needed for proxy testing - testRuntimeOnly "io.netty.contrib:netty-handler-proxy:$nettyContribVersion" + testRuntimeOnly "io.netty.contrib:netty-handler-proxy:$nettyContribHandlerProxyVersion" testRuntimeOnly "io.netty.contrib:netty-codec-haproxy:$nettyContribVersion" // Needed for HTTP/2 testing testRuntimeOnly "io.netty:netty-tcnative-boringssl-static:$boringSslVersion$os_suffix" @@ -259,7 +260,7 @@ task japicmp(type: JapicmpTask) { methodExcludes = [ 'reactor.netty.http.server.logging.AccessLogArgProvider#connectionInformation()', 'reactor.netty.http.server.HttpServerRequest#scheme()', - + 'reactor.netty.http.HttpOperations#send(org.reactivestreams.Publisher)', 'reactor.netty.http.client.HttpClient$ResponseReceiver#responseContent()', diff --git a/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientConfig.java b/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientConfig.java index dc9143baa6..2f96ac3024 100644 --- a/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientConfig.java +++ b/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientConfig.java @@ -60,6 +60,7 @@ import io.netty5.handler.timeout.ReadTimeoutHandler; import io.netty5.resolver.AddressResolverGroup; import org.reactivestreams.Publisher; +import org.slf4j.event.Level; import reactor.core.publisher.Mono; import reactor.netty5.ChannelPipelineConfigurer; import reactor.netty5.Connection; @@ -578,7 +579,7 @@ static void configureHttp2Pipeline(ChannelPipeline p, boolean acceptGzip, HttpRe .initialSettings(http2Settings); if (p.get(NettyPipeline.LoggingHandler) != null) { - http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, + http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(Level.DEBUG, "reactor.netty5.http.client.h2")); } @@ -613,7 +614,7 @@ static void configureHttp11OrH2CleartextPipeline( .initialSettings(http2Settings); if (p.get(NettyPipeline.LoggingHandler) != null) { - http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, + http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(Level.DEBUG, "reactor.netty5.http.client.h2")); } diff --git a/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerConfig.java b/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerConfig.java index 09083b5a2c..91cc477e8f 100644 --- a/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerConfig.java +++ b/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerConfig.java @@ -43,6 +43,7 @@ import io.netty5.handler.ssl.ApplicationProtocolNegotiationHandler; import io.netty5.util.AsciiString; import io.netty5.util.concurrent.Future; +import org.slf4j.event.Level; import reactor.core.publisher.Mono; import reactor.netty5.ChannelPipelineConfigurer; import reactor.netty5.Connection; @@ -506,7 +507,7 @@ static void configureH2Pipeline(ChannelPipeline p, .initialSettings(http2Settings); if (p.get(NettyPipeline.LoggingHandler) != null) { - http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, + http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(Level.DEBUG, "reactor.netty5.http.server.h2")); } @@ -900,7 +901,7 @@ static final class Http11OrH2CleartextCodec extends ChannelInitializer if (debug) { http2FrameCodecBuilder.frameLogger(new Http2FrameLogger( - LogLevel.DEBUG, + Level.DEBUG, "reactor.netty5.http.server.h2")); } this.httpMessageLogFactory = httpMessageLogFactory; diff --git a/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientTest.java b/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientTest.java index 89320b8034..bf82674a12 100644 --- a/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientTest.java +++ b/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientTest.java @@ -97,6 +97,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.reactivestreams.Publisher; +import org.slf4j.event.Level; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.Sinks; @@ -2612,7 +2613,7 @@ void testLoopAndResolver() { .verify(Duration.ofSeconds(30)); StepVerifier.create(client.runOn(loop, false) - .resolver(spec -> spec.trace("reactor.netty5.testLoopAndResolver", LogLevel.DEBUG)) + .resolver(spec -> spec.trace("reactor.netty5.testLoopAndResolver", Level.DEBUG)) .get() .uri("https://example.com") .response((r, buf) -> Mono.just(r.status().code())))