in src/main/java/org/apache/log4j/net/JsonReceiver.java [176:220]
private void parseIncomingData(Socket sock){
InputStream is;
try {
is = sock.getInputStream();
} catch (Exception e) {
is = null;
logger.error("Exception opening InputStream to " + sock, e);
return;
}
if (is != null) {
Genson genson = new GensonBuilder()
.useDateAsTimestamp(true)
.create();
try {
//read data from the socket.
// Once we have a full JSON message, parse it
ChainsawLoggingEventBuilder build = new ChainsawLoggingEventBuilder();
while (true) {
logger.debug( "About to deserialize values" );
Iterator<ECSLogEvent> iter = genson.deserializeValues(is, ECSLogEvent.class);
// Because the socket can be closed, if we don't have anything parsed
// assume that the socket is closed.
if( !iter.hasNext() ) break;
while( iter.hasNext() ){
ECSLogEvent evt = iter.next();
append(evt.toChainsawLoggingEvent(build));
}
}
} catch (Exception e) {
logger.error("Unexpected exception. Closing connection.", e);
}
}
// close the socket
try {
if (is != null) {
is.close();
}
} catch (Exception e) {
//logger.info("Could not close connection.", e);
}
}