Skip to content

Commit

Permalink
Adapt to Netty5 SLF4J changes (#2749)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pderop committed Mar 28, 2023
1 parent e47e072 commit 3910a57
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 66 deletions.
96 changes: 52 additions & 44 deletions .github/workflows/check_transport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
# 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
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion reactor-netty5-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -749,7 +749,7 @@ public NameResolverSpec searchDomains(List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions reactor-netty5-examples/build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
9 changes: 5 additions & 4 deletions reactor-netty5-http/build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -148,14 +148,15 @@ 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"
testRuntimeOnly "org.slf4j:jcl-over-slf4j:$slf4jVersion"
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"
Expand Down Expand Up @@ -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()',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}

Expand Down Expand Up @@ -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"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}

Expand Down Expand Up @@ -900,7 +901,7 @@ static final class Http11OrH2CleartextCodec extends ChannelInitializer<Channel>

if (debug) {
http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(
LogLevel.DEBUG,
Level.DEBUG,
"reactor.netty5.http.server.h2"));
}
this.httpMessageLogFactory = httpMessageLogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())))
Expand Down

0 comments on commit 3910a57

Please sign in to comment.