LOGGER.error("Error occurred during listening.", ttx);
return;
}
while (!stopped_) {
TTransport client = null;
TProcessor processor = null;
TTransport inputTransport = null;
TTransport outputTransport = null;
TProtocol inputProtocol = null;
TProtocol outputProtocol = null;
try {
client = serverTransport_.accept();
if (client != null) {
processor = processorFactory_.getProcessor(client);
inputTransport = inputTransportFactory_.getTransport(client);
inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
// THeaderProtocol must be the same instance for both input and output
if (inputProtocol instanceof THeaderProtocol) {
outputProtocol = inputProtocol;
} else {
outputTransport = outputTransportFactory_.getTransport(client);
outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
}
TRpcConnectionContext server_ctx = new TRpcConnectionContext(client,
inputProtocol,
outputProtocol);
while (processor.process(inputProtocol, outputProtocol, server_ctx)) {}
}
} catch (TTransportException ttx) {
// Client died, just move on
} catch (TException tx) {
if (!stopped_) {
LOGGER.error("Thrift error occurred during processing of message.", tx);
}
} catch (Exception x) {
if (!stopped_) {
LOGGER.error("Error occurred during processing of message.", x);
}
}
if (inputTransport != null) {
inputTransport.close();
}
if (outputTransport != null) {
outputTransport.close();
}
}
}