amalsaidov opened a new pull request, #29851:
URL: https://github.com/apache/camel/pull/29851

   # Description
   
   `StringHelper.splitOnCharacter(String value, String needle, int count)` 
accepts a `String` separator but advanced past each match with `substring(p + 
1)`, which only steps over a single character. When the separator is longer 
than one character, the leftover separator characters leaked into the following 
value.
   
   For example:
   
   ```java
   StringHelper.splitOnCharacter("foo::bar", "::", 2)
   ```
   
   returned `["foo", ":bar"]` instead of `["foo", "bar"]`.
   
   The fix advances by `needle.length()` instead of a fixed `1`. All current 
callers pass a single-character separator (`:`, `,`, `}`), so their behaviour 
is unchanged because `needle.length()` is `1` in those cases.
   
   Also added a test for multi-character separators and javadoc describing the 
method, including the `count` and trailing-`null` semantics.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   
   - [ ] Trivial, self-contained fix with no behaviour change for existing 
callers, so no JIRA issue was filed (per the contribution note on trivial 
changes).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run the build locally for the touched module; there are no 
auto-generated changes to commit.
   
   Tested with `mvn -pl core/camel-util -am test -Dtest=StringHelperTest` (49 
tests pass). Confirmed the new test fails before the fix (`expected: <bar> but 
was: <:bar>`) and passes after.
   
   # AI-assisted contributions
   
   - [x] AI-assisted (Claude Code), directed, reviewed and tested by the author 
(amalsaidov). Commit carries a `Co-authored-by` trailer.
   


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

Reply via email to