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:
Ursprung
b78b091b33
Commit
1f5b0e1e03
@ -63,7 +63,7 @@ public class Java11VelocityCompressor implements VelocityCompressor {
|
|||||||
checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers");
|
checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int origIdx = source.readerIndex();
|
final int origIdx = source.readerIndex();
|
||||||
INFLATE_SET_INPUT.invokeExact(inflater, source.nioBuffer());
|
INFLATE_SET_INPUT.invokeExact(inflater, source.nioBuffer());
|
||||||
|
|
||||||
while (!inflater.finished() && inflater.getBytesRead() < source.readableBytes()) {
|
while (!inflater.finished() && inflater.getBytesRead() < source.readableBytes()) {
|
||||||
@ -75,10 +75,10 @@ public class Java11VelocityCompressor implements VelocityCompressor {
|
|||||||
ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(),
|
ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(),
|
||||||
destination.writableBytes());
|
destination.writableBytes());
|
||||||
int produced = (int) INFLATE_CALL.invokeExact(inflater, destNioBuf);
|
int produced = (int) INFLATE_CALL.invokeExact(inflater, destNioBuf);
|
||||||
source.readerIndex(origIdx + inflater.getTotalIn());
|
|
||||||
destination.writerIndex(destination.writerIndex() + produced);
|
destination.writerIndex(destination.writerIndex() + produced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source.readerIndex(origIdx + inflater.getTotalIn());
|
||||||
inflater.reset();
|
inflater.reset();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (e instanceof DataFormatException) {
|
if (e instanceof DataFormatException) {
|
||||||
@ -97,7 +97,7 @@ public class Java11VelocityCompressor implements VelocityCompressor {
|
|||||||
checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers");
|
checkArgument(destination.nioBufferCount() == 1, "destination has multiple backing buffers");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int origIdx = source.readerIndex();
|
final int origIdx = source.readerIndex();
|
||||||
DEFLATE_SET_INPUT.invokeExact(deflater, source.nioBuffer());
|
DEFLATE_SET_INPUT.invokeExact(deflater, source.nioBuffer());
|
||||||
deflater.finish();
|
deflater.finish();
|
||||||
|
|
||||||
@ -109,10 +109,10 @@ public class Java11VelocityCompressor implements VelocityCompressor {
|
|||||||
ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(),
|
ByteBuffer destNioBuf = destination.nioBuffer(destination.writerIndex(),
|
||||||
destination.writableBytes());
|
destination.writableBytes());
|
||||||
int produced = (int) DEFLATE_CALL.invokeExact(deflater, destNioBuf);
|
int produced = (int) DEFLATE_CALL.invokeExact(deflater, destNioBuf);
|
||||||
source.readerIndex(origIdx + deflater.getTotalIn());
|
|
||||||
destination.writerIndex(destination.writerIndex() + produced);
|
destination.writerIndex(destination.writerIndex() + produced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source.readerIndex(origIdx + deflater.getTotalIn());
|
||||||
deflater.reset();
|
deflater.reset();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (e instanceof DataFormatException) {
|
if (e instanceof DataFormatException) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren