Search in sources :

Example 6 with UnsafeByteArrayOutputStream

use of org.apache.dubbo.common.io.UnsafeByteArrayOutputStream in project dubbo by alibaba.

the class ExchangeCodecTest method getReadonlyEventRequestBytes.

private byte[] getReadonlyEventRequestBytes(Object obj, byte[] header) throws IOException {
    // encode request data.
    UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream(1024);
    ObjectOutput out = serialization.serialize(url, bos);
    out.writeObject(obj);
    out.flushBuffer();
    bos.flush();
    bos.close();
    byte[] data = bos.toByteArray();
    // byte[] len = Bytes.int2bytes(data.length);
    System.arraycopy(data, 0, header, 12, data.length);
    byte[] request = join(header, data);
    return request;
}
Also used : ObjectOutput(org.apache.dubbo.common.serialize.ObjectOutput) UnsafeByteArrayOutputStream(org.apache.dubbo.common.io.UnsafeByteArrayOutputStream)

Aggregations

UnsafeByteArrayOutputStream (org.apache.dubbo.common.io.UnsafeByteArrayOutputStream)6 ObjectOutput (org.apache.dubbo.common.serialize.ObjectOutput)4 Serialization (org.apache.dubbo.common.serialize.Serialization)3 IOException (java.io.IOException)2 RemotingException (org.apache.dubbo.remoting.RemotingException)1 Response (org.apache.dubbo.remoting.exchange.Response)1 RpcException (org.apache.dubbo.rpc.RpcException)1 GenericException (org.apache.dubbo.rpc.service.GenericException)1