public T parseFrom(byte[] b) throws IOException { return parseFrom(new UnsafeByteArrayInputStream(b)); }
@Override public Serializable parseFrom(GenericObjectInput in) throws IOException { byte b = in.read0(); if( b == OBJECT_NULL ) return null; if( b != OBJECT_STREAM ) throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + "."); UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt())); CompactedObjectInputStream ois = new CompactedObjectInputStream(bis); try{ return (Serializable)ois.readObject(); } catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); } } };
/** * unzip. * * @param bytes compressed byte array. * @return byte uncompressed array. * @throws IOException */ public static byte[] unzip(byte[] bytes) throws IOException { UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes); UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(); InputStream is = new InflaterInputStream(bis); try { IOUtils.write(is, bos); return bos.toByteArray(); } finally { is.close(); bis.close(); bos.close(); } }
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException { byte[] bytes = new byte[buffer.readableBytes()]; int savedReaderIndex = buffer.readerIndex(); buffer.readBytes(bytes); UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes); Object result = codec.decode(channel, is); buffer.readerIndex(savedReaderIndex + is.position()); return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result; }
if (byte[].class == args[i].getClass()) { try { UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[]) args[i]); args[i] = ExtensionExtendUtil .getExtension(Serialization.class, Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
} else { result = new DecodeableRpcResult(channel, res, new UnsafeByteArrayInputStream(readMessageData(is)), (Invocation) getRequestData(id), proto); } else { inv = new DecodeableRpcInvocation(channel, req, new UnsafeByteArrayInputStream(readMessageData(is)), proto);