From faf573ff5aa55a4392b1edec995bd6bf5aa850fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Fri, 5 Jun 2020 10:40:42 +0200 Subject: [PATCH] update to Netty 4.1.50, better named modules --- gradle.properties | 9 +++--- gradle/compile/java.gradle | 10 ++++++- .../src/main/java/module-info.java | 4 +-- .../src/main/java/module-info.java | 4 +-- .../src/main/java/module-info.java | 9 +++--- .../org/xbib/netty/http/client/Client.java | 13 --------- .../src/main/java/module-info.java | 5 +++- netty-http-rx/build.gradle | 2 +- .../io/reactivex/netty/util/CollectBytes.java | 1 + .../internal/HttpClientRequestImplTest.java | 4 +-- .../src/main/java/module-info.java | 2 +- .../src/main/java/module-info.java | 4 +-- .../org/xbib/netty/http/server/Server.java | 29 +++++-------------- .../handler/http/Http1ChannelInitializer.java | 6 ++-- .../http2/Http2ChannelInitializer.java | 6 ++-- 15 files changed, 45 insertions(+), 63 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9d9bb49..25855fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group = org.xbib name = netty-http -version = 4.1.49.1 +version = 4.1.50.0 gradle.wrapper.version = 6.4.1 -netty.version = 4.1.49.Final +netty.version = 4.1.50.Final tcnative.version = 2.0.29.Final tcnative-legacy-macosx.version = 2.0.26.Final xbib.net.version = 2.0.4 @@ -12,8 +12,9 @@ reactivestreams.version = 1.0.2 xbib-guice.version = 4.0.4 reactivex.version = 1.3.8 conscrypt.version = 2.2.1 -jackson.version = 2.9.10 -mockito.version = 3.1.0 +jackson.version = 2.11.0 +mockito.version = 3.3.3 asciidoclet.version = 1.5.6 +# uuhh, too many tests to update in rx junit.version = 5.6.2 junit4.version = 4.13 diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle index 3b74bfc..db72f9f 100644 --- a/gradle/compile/java.gradle +++ b/gradle/compile/java.gradle @@ -34,4 +34,12 @@ task javadocJar(type: Jar, dependsOn: javadoc) { artifacts { archives sourcesJar, javadocJar -} \ No newline at end of file +} + +tasks.withType(JavaCompile) { + options.compilerArgs << '-Xlint:all,-exports' +} + +javadoc { + options.addStringOption('Xdoclint:none', '-quiet') +} diff --git a/netty-http-client-api/src/main/java/module-info.java b/netty-http-client-api/src/main/java/module-info.java index 36a7408..4c0486c 100644 --- a/netty-http-client-api/src/main/java/module-info.java +++ b/netty-http-client-api/src/main/java/module-info.java @@ -1,10 +1,10 @@ module org.xbib.netty.http.client.api { exports org.xbib.netty.http.client.api; - requires org.xbib.netty.http.common; + requires transitive org.xbib.netty.http.common; requires org.xbib.net.url; - requires io.netty.transport; requires io.netty.buffer; requires io.netty.common; requires io.netty.codec.http; requires io.netty.codec.http2; + requires io.netty.transport; } diff --git a/netty-http-client-rest/src/main/java/module-info.java b/netty-http-client-rest/src/main/java/module-info.java index adbb525..23bd97c 100644 --- a/netty-http-client-rest/src/main/java/module-info.java +++ b/netty-http-client-rest/src/main/java/module-info.java @@ -1,8 +1,6 @@ module org.xbib.netty.http.client.rest { exports org.xbib.netty.http.client.rest; - requires org.xbib.netty.http.client.api; - requires org.xbib.netty.http.client; - requires org.xbib.netty.http.common; + requires transitive org.xbib.netty.http.client; requires org.xbib.net.url; requires io.netty.buffer; requires io.netty.codec.http; diff --git a/netty-http-client/src/main/java/module-info.java b/netty-http-client/src/main/java/module-info.java index f1f7be9..784326e 100644 --- a/netty-http-client/src/main/java/module-info.java +++ b/netty-http-client/src/main/java/module-info.java @@ -6,16 +6,15 @@ module org.xbib.netty.http.client { exports org.xbib.netty.http.client.pool; exports org.xbib.netty.http.client.retry; exports org.xbib.netty.http.client.transport; - requires org.xbib.netty.http.client.api; - requires org.xbib.netty.http.common; + requires transitive org.xbib.netty.http.client.api; requires org.xbib.net.url; - requires io.netty.transport; requires io.netty.buffer; requires io.netty.common; - requires io.netty.handler; - requires io.netty.handler.proxy; requires io.netty.codec.http; requires io.netty.codec.http2; + requires io.netty.handler; + requires io.netty.handler.proxy; + requires io.netty.transport; requires java.logging; provides org.xbib.netty.http.client.api.ProtocolProvider with org.xbib.netty.http.client.Http1Provider, diff --git a/netty-http-client/src/main/java/org/xbib/netty/http/client/Client.java b/netty-http-client/src/main/java/org/xbib/netty/http/client/Client.java index bbb02f1..dd17abe 100644 --- a/netty-http-client/src/main/java/org/xbib/netty/http/client/Client.java +++ b/netty-http-client/src/main/java/org/xbib/netty/http/client/Client.java @@ -16,7 +16,6 @@ import io.netty.handler.proxy.HttpProxyHandler; import io.netty.handler.ssl.ApplicationProtocolConfig; import io.netty.handler.ssl.ApplicationProtocolNames; import io.netty.handler.ssl.CipherSuiteFilter; -import io.netty.handler.ssl.OpenSsl; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslHandler; @@ -216,18 +215,6 @@ public final class Client implements AutoCloseable { return pool != null && !clientConfig.getPoolNodes().isEmpty(); } - public void logDiagnostics(Level level) { - logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS); - logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS); - logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable()); - logger.log(level, () -> "Candidate ciphers on client: " + clientConfig.getCiphers()); - logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost")); - logger.log(level, () -> "Event loop group: " + eventLoopGroup + " threads=" + clientConfig.getThreadCount()); - logger.log(level, () -> "Socket: " + socketChannelClass.getName()); - logger.log(level, () -> "Allocator: " + byteBufAllocator.getClass().getName()); - logger.log(level, NetworkUtils::displayNetworkInterfaces); - } - public AtomicLong getRequestCounter() { return requestCounter; } diff --git a/netty-http-common/src/main/java/module-info.java b/netty-http-common/src/main/java/module-info.java index 9974dc4..94399df 100644 --- a/netty-http-common/src/main/java/module-info.java +++ b/netty-http-common/src/main/java/module-info.java @@ -5,8 +5,11 @@ module org.xbib.netty.http.common { exports org.xbib.netty.http.common.mime; exports org.xbib.netty.http.common.security; exports org.xbib.netty.http.common.util; + requires transitive org.xbib.net.url; + requires io.netty.buffer; + requires io.netty.common; requires io.netty.transport; requires io.netty.handler; - requires org.xbib.net.url; + requires io.netty.codec.http; requires java.logging; } diff --git a/netty-http-rx/build.gradle b/netty-http-rx/build.gradle index 08d771f..df6cb51 100644 --- a/netty-http-rx/build.gradle +++ b/netty-http-rx/build.gradle @@ -3,6 +3,6 @@ dependencies { implementation "io.netty:netty-codec-http:${project.property('netty.version')}" implementation "io.netty:netty-transport-native-epoll:${project.property('netty.version')}" testImplementation "org.mockito:mockito-core:${project.property('mockito.version')}" - testImplementation "org.junit.vintage:junit-vintage-engine:${project.property('junit.version')}" + testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${project.property('junit.version')}" testImplementation "junit:junit:${project.property('junit4.version')}" } diff --git a/netty-http-rx/src/main/java/io/reactivex/netty/util/CollectBytes.java b/netty-http-rx/src/main/java/io/reactivex/netty/util/CollectBytes.java index ee2fb22..793de08 100644 --- a/netty-http-rx/src/main/java/io/reactivex/netty/util/CollectBytes.java +++ b/netty-http-rx/src/main/java/io/reactivex/netty/util/CollectBytes.java @@ -100,6 +100,7 @@ public class CollectBytes implements Transformer { .cast(ByteBuf.class); } + @SuppressWarnings("serial") public static class TooMuchDataException extends RuntimeException { public TooMuchDataException(String message) { super(message); diff --git a/netty-http-rx/src/test/java/io/reactivex/netty/protocol/http/client/internal/HttpClientRequestImplTest.java b/netty-http-rx/src/test/java/io/reactivex/netty/protocol/http/client/internal/HttpClientRequestImplTest.java index 5048b50..e7d113e 100644 --- a/netty-http-rx/src/test/java/io/reactivex/netty/protocol/http/client/internal/HttpClientRequestImplTest.java +++ b/netty-http-rx/src/test/java/io/reactivex/netty/protocol/http/client/internal/HttpClientRequestImplTest.java @@ -313,7 +313,7 @@ public class HttpClientRequestImplTest { } @Test(timeout = 60000) - public void testSetDateHeader() throws Exception { + public void testSetDateHeader() { String headerName = "date"; Date date1 = new Date(); @@ -754,7 +754,7 @@ public class HttpClientRequestImplTest { public void assertHeaderAdded(HttpClientRequestImpl newReq, String headerName, Date... dates) { - SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss z", Locale.ENGLISH); + SimpleDateFormat sdf = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z", Locale.US); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String[] expectedValues = new String[dates.length]; diff --git a/netty-http-server-api/src/main/java/module-info.java b/netty-http-server-api/src/main/java/module-info.java index 3cdd793..c349050 100644 --- a/netty-http-server-api/src/main/java/module-info.java +++ b/netty-http-server-api/src/main/java/module-info.java @@ -1,8 +1,8 @@ module org.xbib.netty.http.server.api { exports org.xbib.netty.http.server.api; exports org.xbib.netty.http.server.api.annotation; + requires transitive org.xbib.netty.http.common; requires org.xbib.net.url; - requires org.xbib.netty.http.common; requires io.netty.buffer; requires io.netty.common; requires io.netty.handler; diff --git a/netty-http-server/src/main/java/module-info.java b/netty-http-server/src/main/java/module-info.java index 6b70833..b26d8f3 100644 --- a/netty-http-server/src/main/java/module-info.java +++ b/netty-http-server/src/main/java/module-info.java @@ -9,14 +9,14 @@ module org.xbib.netty.http.server { exports org.xbib.netty.http.server.handler.stream; exports org.xbib.netty.http.server.transport; exports org.xbib.netty.http.server.util; - requires org.xbib.netty.http.server.api; - requires org.xbib.netty.http.common; + requires transitive org.xbib.netty.http.server.api; requires org.xbib.net.url; requires io.netty.buffer; requires io.netty.common; requires io.netty.handler; requires io.netty.transport; requires io.netty.codec.http; + requires io.netty.codec.http2; requires java.logging; provides org.xbib.netty.http.server.api.ProtocolProvider with org.xbib.netty.http.server.Http1Provider, diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java index 5c81f6b..6b3d8e8 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/Server.java @@ -11,10 +11,9 @@ import io.netty.channel.socket.ServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.http.HttpVersion; import io.netty.handler.logging.LoggingHandler; -import io.netty.handler.ssl.OpenSsl; import io.netty.handler.ssl.SslContext; -import io.netty.util.DomainNameMapping; -import io.netty.util.DomainNameMappingBuilder; +import io.netty.util.DomainWildcardMappingBuilder; +import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.common.NetworkUtils; import org.xbib.netty.http.common.TransportProvider; @@ -140,10 +139,10 @@ public final class Server implements AutoCloseable { if (serverConfig.getDefaultDomain() == null) { throw new IllegalStateException("no default named server (with name '*') configured, unable to continue"); } - DomainNameMapping domainNameMapping = null; + Mapping domainNameMapping = null; if (serverConfig.getAddress().isSecure() && serverConfig.getDefaultDomain().getSslContext() != null) { - DomainNameMappingBuilder mappingBuilder = - new DomainNameMappingBuilder<>(serverConfig.getDefaultDomain().getSslContext()); + DomainWildcardMappingBuilder mappingBuilder = + new DomainWildcardMappingBuilder<>(serverConfig.getDefaultDomain().getSslContext()); for (Domain domain : serverConfig.getDomains()) { String name = domain.getName(); if (!"*".equals(name)) { @@ -229,20 +228,6 @@ public final class Server implements AutoCloseable { return executor; } - public void logDiagnostics(Level level) { - logger.log(level, () -> "JDK ciphers: " + SecurityUtil.Defaults.JDK_CIPHERS); - logger.log(level, () -> "OpenSSL ciphers: " + SecurityUtil.Defaults.OPENSSL_CIPHERS); - logger.log(level, () -> "OpenSSL available: " + OpenSsl.isAvailable()); - logger.log(level, () -> "Installed ciphers on default server: " + - (serverConfig.getAddress().isSecure() ? serverConfig.getDefaultDomain().getSslContext().cipherSuites() : "")); - logger.log(level, () -> "Local host name: " + NetworkUtils.getLocalHostName("localhost")); - logger.log(level, () -> "Parent event loop group: " + parentEventLoopGroup + " threads=" + serverConfig.getParentThreadCount()); - logger.log(level, () -> "Child event loop group: " + childEventLoopGroup + " threads=" +serverConfig.getChildThreadCount()); - logger.log(level, () -> "Socket: " + socketChannelClass.getName()); - logger.log(level, () -> "Allocator: " + byteBufAllocator.getClass().getName()); - logger.log(level, NetworkUtils::displayNetworkInterfaces); - } - public AtomicLong getRequestCounter() { return requestCounter; } @@ -306,12 +291,12 @@ public final class Server implements AutoCloseable { private HttpChannelInitializer findChannelInitializer(int majorVersion, HttpAddress httpAddress, - DomainNameMapping domainNameMapping) { + Mapping domainNameMapping) { for (ProtocolProvider protocolProvider : protocolProviders) { if (protocolProvider.supportsMajorVersion(majorVersion)) { try { return protocolProvider.initializerClass() - .getConstructor(Server.class, HttpAddress.class, DomainNameMapping.class) + .getConstructor(Server.class, HttpAddress.class, Mapping.class) .newInstance(this, httpAddress, domainNameMapping); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new IllegalStateException(); diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java index e60d5ea..d64a1e8 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http/Http1ChannelInitializer.java @@ -18,7 +18,7 @@ import io.netty.handler.codec.http.HttpVersion; import io.netty.handler.logging.LogLevel; import io.netty.handler.ssl.SslContext; import io.netty.handler.stream.ChunkedWriteHandler; -import io.netty.util.DomainNameMapping; +import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.ServerConfig; @@ -43,11 +43,11 @@ public class Http1ChannelInitializer extends ChannelInitializer private final HttpAddress httpAddress; - private final DomainNameMapping domainNameMapping; + private final Mapping domainNameMapping; public Http1ChannelInitializer(Server server, HttpAddress httpAddress, - DomainNameMapping domainNameMapping) { + Mapping domainNameMapping) { this.server = server; this.serverConfig = server.getServerConfig(); this.httpAddress = httpAddress; diff --git a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java index 8d68704..0352231 100644 --- a/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java +++ b/netty-http-server/src/main/java/org/xbib/netty/http/server/handler/http2/Http2ChannelInitializer.java @@ -30,7 +30,7 @@ import io.netty.handler.logging.LogLevel; import io.netty.handler.ssl.SslContext; import io.netty.handler.stream.ChunkedWriteHandler; import io.netty.util.AsciiString; -import io.netty.util.DomainNameMapping; +import io.netty.util.Mapping; import org.xbib.netty.http.common.HttpAddress; import org.xbib.netty.http.server.Server; import org.xbib.netty.http.server.ServerConfig; @@ -55,11 +55,11 @@ public class Http2ChannelInitializer extends ChannelInitializer private final HttpAddress httpAddress; - private final DomainNameMapping domainNameMapping; + private final Mapping domainNameMapping; public Http2ChannelInitializer(Server server, HttpAddress httpAddress, - DomainNameMapping domainNameMapping) { + Mapping domainNameMapping) { this.server = server; this.serverConfig = server.getServerConfig(); this.httpAddress = httpAddress;