Search in sources :

Example 6 with Cleanable

use of org.apache.dubbo.common.serialize.Cleanable in project dubbo by alibaba.

the class DecodeableRpcResult method decode.

@Override
public Object decode(Channel channel, InputStream input) throws IOException {
    if (log.isDebugEnabled()) {
        Thread thread = Thread.currentThread();
        log.debug("Decoding in thread -- [" + thread.getName() + "#" + thread.getId() + "]");
    }
    ObjectInput in = CodecSupport.getSerialization(channel.getUrl(), serializationType).deserialize(channel.getUrl(), input);
    byte flag = in.readByte();
    switch(flag) {
        case DubboCodec.RESPONSE_NULL_VALUE:
            break;
        case DubboCodec.RESPONSE_VALUE:
            handleValue(in);
            break;
        case DubboCodec.RESPONSE_WITH_EXCEPTION:
            handleException(in);
            break;
        case DubboCodec.RESPONSE_NULL_VALUE_WITH_ATTACHMENTS:
            handleAttachment(in);
            break;
        case DubboCodec.RESPONSE_VALUE_WITH_ATTACHMENTS:
            handleValue(in);
            handleAttachment(in);
            break;
        case DubboCodec.RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS:
            handleException(in);
            handleAttachment(in);
            break;
        default:
            throw new IOException("Unknown result flag, expect '0' '1' '2' '3' '4' '5', but received: " + flag);
    }
    if (in instanceof Cleanable) {
        ((Cleanable) in).cleanup();
    }
    return this;
}
Also used : ObjectInput(org.apache.dubbo.common.serialize.ObjectInput) IOException(java.io.IOException) Cleanable(org.apache.dubbo.common.serialize.Cleanable)

Aggregations

Cleanable (org.apache.dubbo.common.serialize.Cleanable)6 IOException (java.io.IOException)3 ObjectInput (org.apache.dubbo.common.serialize.ObjectInput)3 ObjectOutput (org.apache.dubbo.common.serialize.ObjectOutput)3 ChannelBufferOutputStream (org.apache.dubbo.remoting.buffer.ChannelBufferOutputStream)3 Serialization (org.apache.dubbo.common.serialize.Serialization)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 RemotingException (org.apache.dubbo.remoting.RemotingException)1 ChannelBufferInputStream (org.apache.dubbo.remoting.buffer.ChannelBufferInputStream)1 Response (org.apache.dubbo.remoting.exchange.Response)1 ExceedPayloadLimitException (org.apache.dubbo.remoting.transport.ExceedPayloadLimitException)1 MethodDescriptor (org.apache.dubbo.rpc.model.MethodDescriptor)1 ServiceDescriptor (org.apache.dubbo.rpc.model.ServiceDescriptor)1 ServiceRepository (org.apache.dubbo.rpc.model.ServiceRepository)1