anshuksi282-ksolves opened a new pull request, #11947:
URL: https://github.com/apache/nifi/pull/11947

   ## Summary
   
   [NIFI-16610](https://issues.apache.org/jira/browse/NIFI-16610)
   Fixes `StreamDemarcator` missing a multi-byte delimiter when the preceding 
bytes contain a partial match of the delimiter.
   
   `nextToken()` reset the match index to `0` when a byte did not match, 
without checking whether that byte or the previous bytes started a new match. 
For example, with the delimiter `\r\n`, the input `msg1\r\r\nmsg2` was returned 
as a single token. Since `PublishKafka` uses `StreamDemarcator` for the 
`Message Demarcator` property, multiple messages could be combined into one 
Kafka message.
   
   The match index now falls back to the longest delimiter prefix that is still 
matched, using a prefix table computed once in the constructor, following the 
Knuth-Morris-Pratt approach. Matching remains linear and does not read buffered 
bytes again.
   
   A new test in `StreamDemarcatorTest` covers delimiters that follow a partial 
match, using several initial buffer sizes.
   
   ## Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue 
created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as 
`NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, 
as such `NIFI-00000`
   - [x] Pull request contains [commits 
signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)
 with a registered key indicating `Verified` status
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing 
changes
   
   ## Verification
   
   ### Build
   
   - [x] Build completed using `./mvnw clean install -P contrib-check`
     - [x] JDK 21
     - [ ] JDK 25
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the Apache License 2.0
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` 
files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] NIFI-16610 Fixed StreamDe... anshuksi282-ksolves (via GitHub) via issues

Reply via email to