use of io.netty.handler.codec.EncoderException in project CodeChickenLib by Chicken-Bones.
the class PacketCustom method decompress.
/**
* Decompresses the remaining ByteBuf (after type has been read) using Snappy
*/
private void decompress() {
Inflater inflater = new Inflater();
try {
int len = readInt();
byte[] out = new byte[len];
inflater.setInput(array(), readerIndex(), readableBytes());
inflater.inflate(out);
clear();
writeByteArray(out);
} catch (Exception e) {
throw new EncoderException(e);
} finally {
inflater.end();
}
}
use of io.netty.handler.codec.EncoderException in project CodeChickenLib by Chicken-Bones.
the class MCDataIO method writeString.
/**
* PacketBuffer.writeString
*/
public static void writeString(MCDataOutput out, String string) {
byte[] abyte = string.getBytes(Charsets.UTF_8);
if (abyte.length > 32767)
throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + 32767 + ")");
out.writeVarInt(abyte.length);
out.writeArray(abyte);
}
use of io.netty.handler.codec.EncoderException in project netty by netty.
the class LengthFieldPrependerTest method testAdjustedLengthLessThanZero.
@Test
public void testAdjustedLengthLessThanZero() throws Exception {
final EmbeddedChannel ch = new EmbeddedChannel(new LengthFieldPrepender(4, -2));
try {
ch.writeOutbound(msg);
fail(EncoderException.class.getSimpleName() + " must be raised.");
} catch (EncoderException e) {
// Expected
}
}
Aggregations