3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-25 15:50:19 +01:00

Fix a few minor issues with the Java 11 compressor

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-11-05 17:07:49 -05:00
Ursprung b78b091b33
Commit 1f5b0e1e03

Datei anzeigen

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