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:
Alberto González Palomo
2017-03-05 22:49:06 +01:00
parent 94091a0f9f
commit 8e64e12fed

View File

@@ -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