Skip to content

Commit

Permalink
feat: Properly match file footers (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfarrell authored and chaochenq committed Oct 8, 2018
1 parent 21705b1 commit f4828b6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
0 setup → setup.sh
100755 → 100644
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ private void getNewCurrentBuffer() {

private R buildRecord(int offset, int length) {
ByteBuffer data = ByteBuffers.getPartialView(currentBuffer, offset, length);

if (fileFooterPattern != null) {
final Matcher fileFooterMatcher = fileFooterPattern.matcher(data.asCharBuffer());
final Matcher fileFooterMatcher = fileFooterPattern.matcher(ByteBuffers.toString(data, StandardCharsets.UTF_8).trim());
if(fileFooterMatcher.matches()) {
stopParsing("End of file reached, file footer pattern matched");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected FileFlow(AgentContext context, Configuration config) {

String footerPattern = readString(FILE_FOOTER_PATTERN, null);

fileFooterPattern = Strings.isNullOrEmpty(footerPattern)? null : Pattern.compile(footerPattern);
fileFooterPattern = Strings.isNullOrEmpty(footerPattern)? null : Pattern.compile(footerPattern, Pattern.MULTILINE);

String terminatorConfig = readString("truncatedRecordTerminator", DEFAULT_TRUNCATED_RECORD_TERMINATOR);
if (terminatorConfig == null || terminatorConfig.getBytes(StandardCharsets.UTF_8).length >= getMaxRecordSizeBytes()) {
Expand Down

0 comments on commit f4828b6

Please sign in to comment.