Auxilus08 opened a new pull request, #7988:
URL: https://github.com/apache/gravitino/pull/7988
### What changes were proposed in this pull request?
Fix `StringIdentifier.removeIdFromComment` method to properly trim trailing
spaces from comments when no identifier is found.
- Modified removeIdFromComment method to return comment.trim() when no
identifier is found
- Added test case testRemoveIdFromCommentTrimsTrailingSpaces to verify the
fix
- Ensures consistent behavior whether identifier is present or not
### Why are the changes needed?
The current implementation inconsistently handles trailing spaces:
- When an identifier is found and removed: returns `comment.substring(0,
indexOf).trim()` (trimmed)
- When no identifier is found: returns `comment` (not trimmed)
This causes the test case `testRemoveIdFromCommentTrimsTrailingSpaces` to
fail because comments with trailing spaces are not properly normalized.
Fix: #7974
### Does this PR introduce _any_ user-facing change?
No. This is a bug fix that makes the behavior more consistent and
predictable. No user-facing APIs are changed.
### How was this patch tested?
- Added new test case `testRemoveIdFromCommentTrimsTrailingSpaces` that
verifies the fix
- Verified existing tests still pass
- The fix ensures both code paths consistently trim whitespace
Test case:
```java
@Test
public void testRemoveIdFromCommentTrimsTrailingSpaces() {
StringIdentifier identifier = StringIdentifier.fromId(42L);
String commentWithSpace = "This is a comment ";
String commentWithId = StringIdentifier.addToComment(identifier,
commentWithSpace);
Assertions.assertEquals(
commentWithSpace.trim(),
StringIdentifier.removeIdFromComment(commentWithId));
}
--
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]