From a16e0b6323eb58a58a8b859b3af6891876598da9 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Wed, 8 Aug 2012 06:54:28 -0500 Subject: [PATCH] Change socket traffic class try-catch. Fixes BUKKIT-2093 --- .../java/net/minecraft/server/NetLoginHandler.java | 2 +- .../java/net/minecraft/server/NetworkManager.java | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index fc4c8c66c0..7c201a8463 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -24,7 +24,7 @@ public class NetLoginHandler extends NetHandler { private SecretKey k = null; public String hostname = ""; // CraftBukkit - add field - public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) { + public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) throws java.io.IOException { // CraftBukkit - throws IOException this.server = minecraftserver; this.networkManager = new NetworkManager(socket, s, this, minecraftserver.E().getPrivate()); this.networkManager.e = 0; diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 21cd9f2acc..fed8a22520 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -5,6 +5,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; import java.net.SocketAddress; +import java.net.SocketException; import java.security.PrivateKey; import java.util.ArrayList; import java.util.Collections; @@ -46,7 +47,7 @@ public class NetworkManager implements INetworkManager { private PrivateKey A = null; private int lowPriorityQueueDelay = 50; - public NetworkManager(Socket socket, String s, NetHandler nethandler, PrivateKey privatekey) { + public NetworkManager(Socket socket, String s, NetHandler nethandler, PrivateKey privatekey) throws IOException { // CraftBukkit - throws IOException this.A = privatekey; this.socket = socket; this.j = socket.getRemoteSocketAddress(); @@ -55,18 +56,12 @@ public class NetworkManager implements INetworkManager { try { socket.setSoTimeout(30000); socket.setTrafficClass(24); - // CraftBukkit start - initialize these in try-catch - this.input = new DataInputStream(socket.getInputStream()); - this.output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), 5120)); - } catch (IOException socketexception) { - // CraftBukkit end + } catch (SocketException socketexception) { System.err.println(socketexception.getMessage()); } - /* CraftBukkit start - moved up this.input = new DataInputStream(socket.getInputStream()); this.output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), 5120)); - // CraftBukkit end */ this.u = new NetworkReaderThread(this, s + " read thread"); this.t = new NetworkWriterThread(this, s + " write thread"); this.u.start();