From 065893b5231b4d88a39f2c94c1335d227f5efec9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 21 Dec 2019 11:52:45 +1100 Subject: [PATCH] Update Netty to 4.1.44.Final and remove usage of some deprecated methods --- native/src/main/java/net/md_5/bungee/jni/NativeCode.java | 4 ++-- pom.xml | 2 +- proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java | 5 ++--- proxy/src/main/java/net/md_5/bungee/http/HttpClient.java | 4 ++-- proxy/src/main/java/net/md_5/bungee/http/HttpHandler.java | 4 ++-- .../src/main/java/net/md_5/bungee/http/HttpInitializer.java | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java index 6c92c1f5..4e4130bc 100644 --- a/native/src/main/java/net/md_5/bungee/jni/NativeCode.java +++ b/native/src/main/java/net/md_5/bungee/jni/NativeCode.java @@ -28,8 +28,8 @@ public final class NativeCode { try { - return ( loaded ) ? nativeImpl.newInstance() : javaImpl.newInstance(); - } catch ( IllegalAccessException | InstantiationException ex ) + return ( loaded ) ? nativeImpl.getDeclaredConstructor().newInstance() : javaImpl.getDeclaredConstructor().newInstance(); + } catch ( ReflectiveOperationException ex ) { throw new RuntimeException( "Error getting instance", ex ); } diff --git a/pom.xml b/pom.xml index 8ea1f089..37d4b242 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ unknown - 4.1.43.Final + 4.1.44.Final 1.7 1.7 UTF-8 diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 983f4ce6..60e2889c 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -1,7 +1,6 @@ package net.md_5.bungee.entitymap; import com.flowpowered.nbt.stream.NBTInputStream; -import com.google.common.base.Throwables; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; @@ -257,7 +256,7 @@ public abstract class EntityMap new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); } catch ( IOException ex ) { - throw Throwables.propagate( ex ); + throw new RuntimeException( ex ); } break; case 15: @@ -305,7 +304,7 @@ public abstract class EntityMap new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); } catch ( IOException ex ) { - throw Throwables.propagate( ex ); + throw new RuntimeException( ex ); } } } diff --git a/proxy/src/main/java/net/md_5/bungee/http/HttpClient.java b/proxy/src/main/java/net/md_5/bungee/http/HttpClient.java index 2feb4d66..f95d5b6f 100644 --- a/proxy/src/main/java/net/md_5/bungee/http/HttpClient.java +++ b/proxy/src/main/java/net/md_5/bungee/http/HttpClient.java @@ -9,7 +9,7 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelOption; import io.netty.channel.EventLoop; import io.netty.handler.codec.http.DefaultHttpRequest; -import io.netty.handler.codec.http.HttpHeaders; +import io.netty.handler.codec.http.HttpHeaderNames; import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpRequest; import io.netty.handler.codec.http.HttpVersion; @@ -81,7 +81,7 @@ public class HttpClient String path = uri.getRawPath() + ( ( uri.getRawQuery() == null ) ? "" : "?" + uri.getRawQuery() ); HttpRequest request = new DefaultHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, path ); - request.headers().set( HttpHeaders.Names.HOST, uri.getHost() ); + request.headers().set( HttpHeaderNames.HOST, uri.getHost() ); future.channel().writeAndFlush( request ); } else diff --git a/proxy/src/main/java/net/md_5/bungee/http/HttpHandler.java b/proxy/src/main/java/net/md_5/bungee/http/HttpHandler.java index 96d0a71d..596ced71 100644 --- a/proxy/src/main/java/net/md_5/bungee/http/HttpHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/http/HttpHandler.java @@ -36,7 +36,7 @@ public class HttpHandler extends SimpleChannelInboundHandler if ( msg instanceof HttpResponse ) { HttpResponse response = (HttpResponse) msg; - int responseCode = response.getStatus().code(); + int responseCode = response.status().code(); if ( responseCode == HttpResponseStatus.NO_CONTENT.code() ) { @@ -46,7 +46,7 @@ public class HttpHandler extends SimpleChannelInboundHandler if ( responseCode != HttpResponseStatus.OK.code() ) { - throw new IllegalStateException( "Expected HTTP response 200 OK, got " + response.getStatus() ); + throw new IllegalStateException( "Expected HTTP response 200 OK, got " + response.status() ); } } if ( msg instanceof HttpContent ) diff --git a/proxy/src/main/java/net/md_5/bungee/http/HttpInitializer.java b/proxy/src/main/java/net/md_5/bungee/http/HttpInitializer.java index ea75dfcd..37657c4c 100644 --- a/proxy/src/main/java/net/md_5/bungee/http/HttpInitializer.java +++ b/proxy/src/main/java/net/md_5/bungee/http/HttpInitializer.java @@ -3,7 +3,7 @@ package net.md_5.bungee.http; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import io.netty.handler.codec.http.HttpClientCodec; -import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslHandler; import io.netty.handler.timeout.ReadTimeoutHandler; import java.util.concurrent.TimeUnit; @@ -26,7 +26,7 @@ public class HttpInitializer extends ChannelInitializer ch.pipeline().addLast( "timeout", new ReadTimeoutHandler( HttpClient.TIMEOUT, TimeUnit.MILLISECONDS ) ); if ( ssl ) { - SSLEngine engine = SslContext.newClientContext().newEngine( ch.alloc(), host, port ); + SSLEngine engine = SslContextBuilder.forClient().build().newEngine( ch.alloc(), host, port ); ch.pipeline().addLast( "ssl", new SslHandler( engine ) ); }