|
8 | 8 | import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
9 | 9 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
10 | 10 | import io.netty.bootstrap.ServerBootstrap;
|
| 11 | +import io.netty.buffer.ByteBuf; |
| 12 | +import io.netty.buffer.Unpooled; |
11 | 13 | import io.netty.channel.Channel;
|
12 | 14 | import io.netty.channel.ChannelException;
|
13 | 15 | import io.netty.channel.ChannelFuture;
|
@@ -230,14 +232,32 @@ public BungeeCord() throws IOException
|
230 | 232 |
|
231 | 233 | if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) )
|
232 | 234 | {
|
233 |
| - if ( EncryptionUtil.nativeFactory.load() ) |
| 235 | + ByteBuf directBuffer = null; |
| 236 | + boolean hasMemoryAddress = false; |
| 237 | + try |
| 238 | + { |
| 239 | + directBuffer = Unpooled.directBuffer(); |
| 240 | + hasMemoryAddress = directBuffer.hasMemoryAddress(); |
| 241 | + } finally |
| 242 | + { |
| 243 | + if ( directBuffer != null ) |
| 244 | + { |
| 245 | + directBuffer.release(); |
| 246 | + } |
| 247 | + } |
| 248 | + if ( !hasMemoryAddress ) |
| 249 | + { |
| 250 | + logger.warning( "Memory addresses are not available in direct buffers" ); |
| 251 | + } |
| 252 | + |
| 253 | + if ( hasMemoryAddress && EncryptionUtil.nativeFactory.load() ) |
234 | 254 | {
|
235 | 255 | logger.info( "Using mbed TLS based native cipher." );
|
236 | 256 | } else
|
237 | 257 | {
|
238 | 258 | logger.info( "Using standard Java JCE cipher." );
|
239 | 259 | }
|
240 |
| - if ( CompressFactory.zlib.load() ) |
| 260 | + if ( hasMemoryAddress && CompressFactory.zlib.load() ) |
241 | 261 | {
|
242 | 262 | logger.info( "Using zlib based native compressor." );
|
243 | 263 | } else
|
|
0 commit comments