Skip to content

Commit 10ae6a9

Browse files
authored
Merge pull request #39 from SpigotMC/master
[pull] master from SpigotMC:master
2 parents 5dafa8b + a336efb commit 10ae6a9

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

proxy/src/main/java/net/md_5/bungee/BungeeCord.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.google.common.util.concurrent.ThreadFactoryBuilder;
99
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1010
import io.netty.bootstrap.ServerBootstrap;
11+
import io.netty.buffer.ByteBuf;
12+
import io.netty.buffer.Unpooled;
1113
import io.netty.channel.Channel;
1214
import io.netty.channel.ChannelException;
1315
import io.netty.channel.ChannelFuture;
@@ -230,14 +232,32 @@ public BungeeCord() throws IOException
230232

231233
if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) )
232234
{
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() )
234254
{
235255
logger.info( "Using mbed TLS based native cipher." );
236256
} else
237257
{
238258
logger.info( "Using standard Java JCE cipher." );
239259
}
240-
if ( CompressFactory.zlib.load() )
260+
if ( hasMemoryAddress && CompressFactory.zlib.load() )
241261
{
242262
logger.info( "Using zlib based native compressor." );
243263
} else

0 commit comments

Comments
 (0)