mirror of
https://github.com/Febbweiss/logstash-forwarder-java.git
synced 2026-03-04 14:15:42 +00:00
Fix sliced multi-line events
The original multi-line implementation had a problem: multi-line events got sliced in two when they crossed the spool size barrier, because the code still counted each line as a spool entry. With multi-line entries that is no longer correct. This fix simply reduces the spaceLeftInSpool variable only after adding an entry.
This commit is contained in:
@@ -150,14 +150,14 @@ public class FileReader extends Reader {
|
||||
pos = reader.getFilePointer();
|
||||
if (multiline == null) {
|
||||
addEvent(state, pos, line);
|
||||
spaceLeftInSpool--;
|
||||
}
|
||||
else {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("-- Multiline : " + multiline);
|
||||
logger.trace("-- Multiline : matches " + multiline.isPatternFound(line));
|
||||
}
|
||||
if (multiline.isPatternFound(line))
|
||||
{
|
||||
if (multiline.isPatternFound(line)) {
|
||||
// buffer the line
|
||||
if (bufferedLines.position() > 0) {
|
||||
bufferedLines.put(Multiline.JOINT);
|
||||
@@ -169,6 +169,7 @@ public class FileReader extends Reader {
|
||||
// did not match, so new event started
|
||||
if (bufferedLines.position() > 0) {
|
||||
addEvent(state, pos, extractBytes(bufferedLines));
|
||||
spaceLeftInSpool--;
|
||||
}
|
||||
bufferedLines.put(line);
|
||||
}
|
||||
@@ -178,14 +179,16 @@ public class FileReader extends Reader {
|
||||
bufferedLines.put(Multiline.JOINT);
|
||||
bufferedLines.put(line);
|
||||
addEvent(state, pos, extractBytes(bufferedLines));
|
||||
spaceLeftInSpool--;
|
||||
}
|
||||
else
|
||||
else {
|
||||
addEvent(state, pos, line);
|
||||
spaceLeftInSpool--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line = readLine(reader);
|
||||
spaceLeftInSpool--;
|
||||
}
|
||||
if (bufferedLines.position() > 0) {
|
||||
addEvent(state, pos, extractBytes(bufferedLines)); // send any buffered lines left
|
||||
|
||||
Reference in New Issue
Block a user