From 961e3ece270626ee65979b21e20a48f17f31a5e4 Mon Sep 17 00:00:00 2001 From: Willsr71 Date: Sat, 27 Apr 2019 19:04:28 -0400 Subject: [PATCH] Fix DataFormatException with java decompression (#195) --- .../natives/compression/JavaVelocityCompressor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/native/src/main/java/com/velocitypowered/natives/compression/JavaVelocityCompressor.java b/native/src/main/java/com/velocitypowered/natives/compression/JavaVelocityCompressor.java index 3a0a7d07c..c948e6ee4 100644 --- a/native/src/main/java/com/velocitypowered/natives/compression/JavaVelocityCompressor.java +++ b/native/src/main/java/com/velocitypowered/natives/compression/JavaVelocityCompressor.java @@ -28,7 +28,8 @@ public class JavaVelocityCompressor implements VelocityCompressor { ensureNotDisposed(); if (source.hasArray()) { - inflater.setInput(source.array(), source.arrayOffset(), source.readableBytes()); + inflater.setInput(source.array(), source.arrayOffset() + source.readerIndex(), + source.readableBytes()); } else { byte[] inData = new byte[source.readableBytes()]; source.readBytes(inData); @@ -47,7 +48,8 @@ public class JavaVelocityCompressor implements VelocityCompressor { ensureNotDisposed(); if (source.hasArray()) { - deflater.setInput(source.array(), source.arrayOffset(), source.readableBytes()); + deflater.setInput(source.array(), source.arrayOffset() + source.readerIndex(), + source.readableBytes()); } else { byte[] inData = new byte[source.readableBytes()]; source.readBytes(inData);