Search in sources :

Example 71 with ByteBufInputStream

use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBufInputStream in project Glowstone by GlowstoneMC.

the class GlowBufUtils method readCompound.

private static CompoundTag readCompound(ByteBuf buf, boolean network) {
    int idx = buf.readerIndex();
    if (buf.readByte() == 0) {
        return null;
    }
    buf.readerIndex(idx);
    try (NbtInputStream str = new NbtInputStream(new ByteBufInputStream(buf), false)) {
        return str.readCompound(network ? new NbtReadLimiter(2097152L) : NbtReadLimiter.UNLIMITED);
    } catch (IOException e) {
        return null;
    }
}
Also used : NbtReadLimiter(net.glowstone.util.nbt.NbtReadLimiter) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) IOException(java.io.IOException) NbtInputStream(net.glowstone.util.nbt.NbtInputStream)

Aggregations

ByteBufInputStream (io.netty.buffer.ByteBufInputStream)69 ByteBuf (io.netty.buffer.ByteBuf)22 IOException (java.io.IOException)22 InputStreamReader (java.io.InputStreamReader)18 BadRequestException (co.cask.cdap.common.BadRequestException)16 Reader (java.io.Reader)16 JsonSyntaxException (com.google.gson.JsonSyntaxException)11 InputStream (java.io.InputStream)10 Path (javax.ws.rs.Path)9 ObjectInputStream (java.io.ObjectInputStream)8 NamespaceId (co.cask.cdap.proto.id.NamespaceId)6 POST (javax.ws.rs.POST)6 Test (org.junit.jupiter.api.Test)5 AuditPolicy (co.cask.cdap.common.security.AuditPolicy)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 ByteBufOutputStream (io.netty.buffer.ByteBufOutputStream)4 RpcException (org.apache.drill.exec.rpc.RpcException)4 UnsupportedTypeException (co.cask.cdap.api.data.schema.UnsupportedTypeException)3 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)3 ObjectOutputStream (java.io.ObjectOutputStream)3