From 0613886659b04bacd353dbdcee657d90536988e2 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sat, 23 Feb 2019 10:12:25 -0300 Subject: [PATCH] Fix memory leak --- .../myles/ViaVersion/bungee/handlers/BungeeDecodeHandler.java | 2 +- .../myles/ViaVersion/bungee/handlers/BungeeEncodeHandler.java | 2 +- .../myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java | 2 +- .../myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java | 2 +- .../ViaVersion/velocity/handlers/VelocityDecodeHandler.java | 2 +- .../ViaVersion/velocity/handlers/VelocityEncodeHandler.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeDecodeHandler.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeDecodeHandler.java index 898df7d11..20d862992 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeDecodeHandler.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeDecodeHandler.java @@ -56,7 +56,7 @@ public class BungeeDecodeHandler extends MessageToMessageDecoder { bytebuf.clear(); bytebuf = newPacket; - } catch (Exception e) { + } catch (Throwable e) { // Clear Buffer bytebuf.clear(); // Release Packet, be free! diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeEncodeHandler.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeEncodeHandler.java index fc39eebdd..34ffb2667 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeEncodeHandler.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/handlers/BungeeEncodeHandler.java @@ -60,7 +60,7 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder { ProtocolInfo protInfo = info.get(ProtocolInfo.class); protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper); wrapper.writeToBuffer(bytebuf); - } catch (Exception e) { + } catch (Throwable e) { bytebuf.clear(); throw e; } finally { diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java index 8ee2180db..cd7f10370 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeDecodeHandler.java @@ -57,7 +57,7 @@ public class SpongeDecodeHandler extends ByteToMessageDecoder { bytebuf.clear(); bytebuf = newPacket; - } catch (Exception e) { + } catch (Throwable e) { // Clear Buffer bytebuf.clear(); // Release Packet, be free! diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java index 8f12b42a4..5db88d64a 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/handlers/SpongeEncodeHandler.java @@ -53,7 +53,7 @@ public class SpongeEncodeHandler extends MessageToByteEncoder { ProtocolInfo protInfo = info.get(ProtocolInfo.class); protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper); wrapper.writeToBuffer(bytebuf); - } catch (Exception e) { + } catch (Throwable e) { bytebuf.clear(); throw e; } finally { diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java index 23dbd77fd..1b4baa8d4 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java @@ -53,7 +53,7 @@ public class VelocityDecodeHandler extends MessageToMessageDecoder { bytebuf.clear(); bytebuf = newPacket; - } catch (Exception e) { + } catch (Throwable e) { // Clear Buffer bytebuf.clear(); // Release Packet, be free! diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java index 1a929c2e8..b671159c5 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java @@ -65,7 +65,7 @@ public class VelocityEncodeHandler extends MessageToMessageEncoder { bytebuf.clear(); bytebuf.release(); bytebuf = newPacket; - } catch (Exception e) { + } catch (Throwable e) { bytebuf.clear(); bytebuf.release(); newPacket.release();