From 1f5b0e1e03dae625a0982a17d74fad0d04ebb047 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 5 Nov 2020 17:07:49 -0500 Subject: [PATCH] Fix a few minor issues with the Java 11 compressor --- .../natives/compression/Java11VelocityCompressor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/native/src/main/java/com/velocitypowered/natives/compression/Java11VelocityCompressor.java b/native/src/main/java/com/velocitypowered/natives/compression/Java11VelocityCompressor.java index 18397fee7..685152d07 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/Java11VelocityCompressor.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/Java11VelocityCompressor.java @@ -63,7 +63,7 @@ public class Java11VelocityCompressor implements VelocityCompressor { checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers"); try { - int origIdx = source.readerIndex(); + final int origIdx = source.readerIndex(); INFLATE_SET_INPUT.invokeExact(inflater, source.nioBuffer()); while (!inflater.finished() && inflater.getBytesRead() < source.readableBytes()) { @@ -75,10 +75,10 @@ public class Java11VelocityCompressor implements VelocityCompressor { ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(), destination.writableBytes()); int produced = (int) INFLATE_CALL.invokeExact(inflater, destNioBuf); - source.readerIndex(origIdx + inflater.getTotalIn()); destination.writerIndex(destination.writerIndex() + produced); } + source.readerIndex(origIdx + inflater.getTotalIn()); inflater.reset(); } catch (Throwable e) { if (e instanceof DataFormatException) { @@ -97,7 +97,7 @@ public class Java11VelocityCompressor implements VelocityCompressor { checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers"); try { - int origIdx = source.readerIndex(); + final int origIdx = source.readerIndex(); DEFLATE_SET_INPUT.invokeExact(deflater, source.nioBuffer()); deflater.finish(); @@ -109,10 +109,10 @@ public class Java11VelocityCompressor implements VelocityCompressor { ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(), destination.writableBytes()); int produced = (int) DEFLATE_CALL.invokeExact(deflater, destNioBuf); - source.readerIndex(origIdx + deflater.getTotalIn()); destination.writerIndex(destination.writerIndex() + produced); } + source.readerIndex(origIdx + deflater.getTotalIn()); deflater.reset(); } catch (Throwable e) { if (e instanceof DataFormatException) {