|
25 | 25 | import io.netty.channel.EventLoopGroup;
|
26 | 26 | import io.netty.channel.group.ChannelGroup;
|
27 | 27 | import io.netty.channel.nio.NioEventLoopGroup;
|
28 |
| -import io.netty.channel.oio.OioEventLoopGroup; |
29 |
| -import io.netty.channel.socket.SocketChannel; |
30 | 28 | import io.netty.channel.socket.nio.NioSocketChannel;
|
31 |
| -import io.netty.channel.socket.oio.OioSocketChannel; |
32 | 29 | import io.netty.handler.codec.http.HttpClientCodec;
|
33 | 30 | import io.netty.handler.codec.http.HttpContentCompressor;
|
34 | 31 | import io.netty.handler.codec.http.HttpContentDecompressor;
|
@@ -112,34 +109,22 @@ public Channels(final AsyncHttpClientConfig config, NettyAsyncHttpProviderConfig
|
112 | 109 | this.config = config;
|
113 | 110 | this.asyncHttpProviderConfig = asyncHttpProviderConfig;
|
114 | 111 |
|
115 |
| - Class<? extends SocketChannel> socketChannelClass = null; |
116 |
| - if (asyncHttpProviderConfig.isUseBlockingIO()) { |
117 |
| - socketChannelClass = OioSocketChannel.class; |
118 |
| - eventLoopGroup = new OioEventLoopGroup(); |
119 |
| - allowReleaseEventLoopGroup = true; |
| 112 | + // check if external EventLoopGroup is defined |
| 113 | + eventLoopGroup = asyncHttpProviderConfig.getEventLoopGroup(); |
120 | 114 |
|
| 115 | + if (eventLoopGroup == null) { |
| 116 | + eventLoopGroup = new NioEventLoopGroup(); |
| 117 | + allowReleaseEventLoopGroup = true; |
121 | 118 | } else {
|
122 |
| - // check if external EventLoopGroup is defined |
123 |
| - eventLoopGroup = asyncHttpProviderConfig.getEventLoopGroup(); |
124 |
| - if (eventLoopGroup instanceof OioEventLoopGroup) { |
125 |
| - socketChannelClass = OioSocketChannel.class; |
126 |
| - allowReleaseEventLoopGroup = false; |
127 |
| - |
128 |
| - } else if (eventLoopGroup instanceof NioEventLoopGroup) { |
129 |
| - socketChannelClass = NioSocketChannel.class; |
130 |
| - allowReleaseEventLoopGroup = false; |
131 |
| - |
132 |
| - } else { |
133 |
| - socketChannelClass = NioSocketChannel.class; |
134 |
| - eventLoopGroup = new NioEventLoopGroup(); |
135 |
| - allowReleaseEventLoopGroup = true; |
136 |
| - } |
| 119 | + if (!(eventLoopGroup instanceof NioEventLoopGroup)) |
| 120 | + throw new IllegalArgumentException("Only Nio is supported"); |
| 121 | + allowReleaseEventLoopGroup = false; |
137 | 122 | }
|
138 | 123 |
|
139 |
| - plainBootstrap = new Bootstrap().channel(socketChannelClass).group(eventLoopGroup); |
140 |
| - secureBootstrap = new Bootstrap().channel(socketChannelClass).group(eventLoopGroup); |
141 |
| - webSocketBootstrap = new Bootstrap().channel(socketChannelClass).group(eventLoopGroup); |
142 |
| - secureWebSocketBootstrap = new Bootstrap().channel(socketChannelClass).group(eventLoopGroup); |
| 124 | + plainBootstrap = new Bootstrap().channel(NioSocketChannel.class).group(eventLoopGroup); |
| 125 | + secureBootstrap = new Bootstrap().channel(NioSocketChannel.class).group(eventLoopGroup); |
| 126 | + webSocketBootstrap = new Bootstrap().channel(NioSocketChannel.class).group(eventLoopGroup); |
| 127 | + secureWebSocketBootstrap = new Bootstrap().channel(NioSocketChannel.class).group(eventLoopGroup); |
143 | 128 |
|
144 | 129 | // This is dangerous as we can't catch a wrong typed ConnectionsPool
|
145 | 130 | ConnectionsPool<String, Channel> cp = (ConnectionsPool<String, Channel>) config.getConnectionsPool();
|
|
0 commit comments