in java/amazon-kinesis-producer/src/main/java/com/amazonaws/services/kinesis/producer/LogInputStreamReader.java [106:150]
public void run() {
while (running) {
String logLine;
try {
logLine = reader.readLine();
// log.info("Considering({}): {}", streamType, logLine);
if (logLine == null) {
continue;
}
if (logLine.startsWith("++++")) {
startRead();
} else if (logLine.startsWith("----")) {
finishRead();
} else if (isReadingRecord) {
messageData.add(logLine);
} else {
logFunction.apply(log, logLine);
}
} catch (IOException ioex) {
if (shuttingDown) {
//
// Since the Daemon calls destroy instead of letting the process exit normally
// the input streams coming from the process will end up truncated.
// When we know the process is shutting down we can report the exception as info
//
if (ioex.getMessage() == null || !ioex.getMessage().contains("Stream closed")) {
//
// If the message is "Stream closed" we can safely ignore it. This is probably a bug
// with the UNIXProcess#ProcessPipeInputStream that it throws the exception. There
// is no other way to detect the other side of the request being closed.
//
log.info("Received IO Exception during shutdown. This can happen, but should indicate "
+ "that the stream has been closed: {}", ioex.getMessage());
}
} else {
log.error("Caught IO Exception while reading log line", ioex);
}
}
}
if (!messageData.isEmpty()) {
logFunction.apply(log, makeMessage());
}
}