List of usage examples for org.apache.thrift.protocol TTupleProtocol readMessageEnd
public void readMessageEnd() throws TException
From source file:net.morimekta.providence.thrift.TTupleProtocolSerializer.java
License:Apache License
@Override @SuppressWarnings("unchecked") public <Message extends PMessage<Message, Field>, Field extends PField> PServiceCall<Message, Field> deserialize( InputStream input, PService service) throws SerializerException { TMessage tm = null;/*from w w w . j a v a2 s . c om*/ PServiceCallType type = null; try { TTransport transport = new TIOStreamTransport(input); TTupleProtocol protocol = (TTupleProtocol) protocolFactory.getProtocol(transport); tm = protocol.readMessageBegin(); type = PServiceCallType.forValue(tm.type); if (type == null) { throw new SerializerException("Unknown call type for id " + tm.type); } else if (type == PServiceCallType.EXCEPTION) { PApplicationException exception = readMessage(protocol, PApplicationException.kDescriptor); return new PServiceCall(tm.name, type, tm.seqid, exception); } PServiceMethod method = service.getMethod(tm.name); if (method == null) { throw new SerializerException("No such method " + tm.name + " on " + service.getQualifiedName()); } PMessageDescriptor<Message, Field> descriptor = isRequestCallType(type) ? method.getRequestType() : method.getResponseType(); Message message = readMessage(protocol, descriptor); protocol.readMessageEnd(); return new PServiceCall<>(tm.name, type, tm.seqid, message); } catch (TTransportException e) { throw new SerializerException(e, "Unable to serialize into transport protocol") .setExceptionType(PApplicationExceptionType.forValue(e.getType())).setCallType(type) .setMethodName(tm != null ? tm.name : "").setSequenceNo(tm != null ? tm.seqid : 0); } catch (TException e) { throw new SerializerException(e, "Transport exception in protocol") .setExceptionType(PApplicationExceptionType.PROTOCOL_ERROR).setCallType(type) .setMethodName(tm != null ? tm.name : "").setSequenceNo(tm != null ? tm.seqid : 0); } }