Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/com/thebuzzmedia/cloudfront/LogParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ public void parse(InputStream stream, ILogParserCallback callback)
int lfIndex = ArrayUtils.lastIndexOfNoCheck(LF, buffer, index,
length);

if (lfIndex == -1)
if (lfIndex == -1 && length < buffer.length / 2) {
// read did not return enough.
System.out.println("reading more without processing, (read() returned less than one record)");
index = length;
continue;
} else if (lfIndex == -1) {
throw new MalformedContentException(
"Could not find the \\n (LINE FEED) character after scanning "
+ length
Expand All @@ -227,7 +232,7 @@ public void parse(InputStream stream, ILogParserCallback callback)
+ " bytes). The log file is likely malformed or a single log entry line is so long it won't fit easily into the current read buffer. Consider making the buffer bigger by adjust the "
+ BUFFER_SIZE_PROPERTY_NAME
+ " system property.");

}
// Decode the buffer contents up to our LF terminator
char[] content = DecodingUtils.decode(buffer,
DecodingUtils.ASCII_CHARSET, index, lfIndex + 1);
Expand Down Expand Up @@ -410,6 +415,13 @@ protected void parseLogEntry(char[] line, int index, int length,
continue;
}

if (valueIndex > activeFieldIndices.size()) {
System.out.println("Error, line has more fields than it should at " + valueIndex +
" line: " + (new String(line)).substring(index, index+length));
skippedFieldPositionSet.add(valueIndex);
continue;
}

// Value belonged to an active field, so store it.
logEntryWrapper.setFieldValue(activeFieldIndices.get(valueIndex++)
.intValue(), token.getValue());
Expand Down