|
38 | 38 | import io.netty.resolver.NameResolver; |
39 | 39 | import io.netty.util.Timer; |
40 | 40 | import io.netty.util.concurrent.*; |
| 41 | +import io.netty.util.internal.PlatformDependent; |
41 | 42 | import org.asynchttpclient.*; |
42 | 43 | import org.asynchttpclient.channel.ChannelPool; |
43 | 44 | import org.asynchttpclient.channel.ChannelPoolPartitioning; |
@@ -188,15 +189,20 @@ private Bootstrap newBootstrap(ChannelFactory<? extends Channel> channelFactory, |
188 | 189 |
|
189 | 190 | @SuppressWarnings("unchecked") |
190 | 191 | private TransportFactory<? extends Channel, ? extends EventLoopGroup> getNativeTransportFactory() { |
| 192 | + String nativeTransportFactoryClassName = null; |
| 193 | + if (PlatformDependent.isOsx()) { |
| 194 | + nativeTransportFactoryClassName = "org.asynchttpclient.netty.channel.KQueueTransportFactory"; |
| 195 | + } else if (!PlatformDependent.isWindows()) { |
| 196 | + nativeTransportFactoryClassName = "org.asynchttpclient.netty.channel.EpollTransportFactory"; |
| 197 | + } |
| 198 | + |
191 | 199 | try { |
192 | | - return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName("org.asynchttpclient.netty.channel.EpollTransportFactory").newInstance(); |
193 | | - } catch (Exception e) { |
194 | | - try { |
195 | | - return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName("org.asynchttpclient.netty.channel.KQueueTransportFactory").newInstance(); |
196 | | - } catch (Exception e1) { |
197 | | - throw new IllegalArgumentException("No suitable native transport (epoll or kqueue) available"); |
| 200 | + if (nativeTransportFactoryClassName != null) { |
| 201 | + return (TransportFactory<? extends Channel, ? extends EventLoopGroup>) Class.forName(nativeTransportFactoryClassName).newInstance(); |
198 | 202 | } |
| 203 | + } catch (Exception e) { |
199 | 204 | } |
| 205 | + throw new IllegalArgumentException("No suitable native transport (epoll or kqueue) available"); |
200 | 206 | } |
201 | 207 |
|
202 | 208 | public void configureBootstraps(NettyRequestSender requestSender) { |
|
0 commit comments