Fixed the issue with last character handling for cases when the length of the message is 4001 characters #1680
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
This fixes the issue that happens when
MessageBuilder#buildAll
is called on a message with 2001+ characters. Once the message is split, the last character of the last message ends up being cut off. The reason this happens is because the endIndex of the substring is set as builder.length()-1, even though a substring's end index is exclusive. As a result, the last char in the StringBuilder of the message ends up being cut off.Tested
With the following sample code
Existing implementation loses last 'c' letter, by generating 2 messages
![image](https://user-images.githubusercontent.com/86025730/122663274-0c5ce180-d14e-11eb-8817-21f3e7ab2972.png)
And proposed implementation correctly generates 3 messages
![image](https://user-images.githubusercontent.com/86025730/122663251-e46d7e00-d14d-11eb-8495-7e62f1ff5fed.png)