From de0c798c450a28a2faabc2631e8df3323ea721b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Thu, 15 Apr 2021 17:14:22 +0200 Subject: [PATCH] update to netty 4.1.63 --- gradle.properties | 6 +++--- gradle/compile/java.gradle | 3 ++- .../org/xbib/netty/http/client/Client.java | 19 ++++++++++++++----- .../http/client/pool/BoundedChannelPool.java | 8 +++++--- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index badcbb4..75a8818 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ group = org.xbib name = netty-http -version = 4.1.60.0 +version = 4.1.63.0 gradle.wrapper.version = 6.6.1 -netty.version = 4.1.60.Final -tcnative.version = 2.0.36.Final +netty.version = 4.1.63.Final +tcnative.version = 2.0.38.Final bouncycastle.version = 1.68 reactivestreams.version = 1.0.2 reactivex.version = 1.3.8 diff --git a/gradle/compile/java.gradle b/gradle/compile/java.gradle index db72f9f..ec9f2e2 100644 --- a/gradle/compile/java.gradle +++ b/gradle/compile/java.gradle @@ -30,6 +30,7 @@ task sourcesJar(type: Jar, dependsOn: classes) { task javadocJar(type: Jar, dependsOn: javadoc) { classifier 'javadoc' + from javadoc.destinationDir } artifacts { @@ -37,7 +38,7 @@ artifacts { } tasks.withType(JavaCompile) { - options.compilerArgs << '-Xlint:all,-exports' + options.compilerArgs << '-Xlint:all' } javadoc { 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 04c1f80..6e20e79 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 @@ -210,6 +210,10 @@ public final class Client implements AutoCloseable { return byteBufAllocator; } + public boolean isPooled() { + return pool != null; + } + public boolean hasPooledConnections() { return pool != null && !clientConfig.getPoolNodes().isEmpty(); } @@ -266,7 +270,6 @@ public final class Client implements AutoCloseable { } public Channel newChannel(HttpAddress httpAddress) throws IOException { - Channel channel; if (httpAddress != null) { HttpVersion httpVersion = httpAddress.getVersion(); SslContext sslContext = newSslContext(clientConfig, httpAddress.getVersion()); @@ -276,7 +279,7 @@ public final class Client implements AutoCloseable { HttpChannelInitializer initializer = findChannelInitializer(httpVersion.majorVersion(), httpAddress, sslHandlerFactory, initializerTwo); try { - channel = bootstrap.handler(initializer) + return bootstrap.handler(initializer) .connect(httpAddress.getInetSocketAddress()).sync().await().channel(); } catch (InterruptedException e) { throw new IOException(e); @@ -284,7 +287,12 @@ public final class Client implements AutoCloseable { } else { if (hasPooledConnections()) { try { - channel = pool.acquire(); + if (pool != null) { + return pool.acquire(); + } else { + logger.log(Level.SEVERE, "no pool prsent"); + return null; + } } catch (Exception e) { throw new IOException(e); } @@ -292,7 +300,6 @@ public final class Client implements AutoCloseable { throw new UnsupportedOperationException(); } } - return channel; } public void releaseChannel(Channel channel, boolean close) throws IOException{ @@ -301,7 +308,9 @@ public final class Client implements AutoCloseable { } if (hasPooledConnections()) { try { - pool.release(channel, close); + if (pool != null) { + pool.release(channel, close); + } } catch (Exception e) { throw new IOException(e); } diff --git a/netty-http-client/src/main/java/org/xbib/netty/http/client/pool/BoundedChannelPool.java b/netty-http-client/src/main/java/org/xbib/netty/http/client/pool/BoundedChannelPool.java index b4cc9ee..ac2b967 100644 --- a/netty-http-client/src/main/java/org/xbib/netty/http/client/pool/BoundedChannelPool.java +++ b/netty-http-client/src/main/java/org/xbib/netty/http/client/pool/BoundedChannelPool.java @@ -173,9 +173,11 @@ public class BoundedChannelPool implements Pool { if (channel != null) { if (channel.isActive()) { K key = channel.attr(attributeKey).get(); - Queue channelQueue = availableChannels.get(key); - if (channelQueue != null) { - channelQueue.add(channel); + if (key != null) { + Queue channelQueue = availableChannels.get(key); + if (channelQueue != null) { + channelQueue.add(channel); + } } } else if (channel.isOpen() && close) { logger.log(Level.FINE, "closing channel " + channel);