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) {