You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "Auxilus08 (via GitHub)" <gi...@apache.org> on 2025/08/08 10:19:54 UTC
[PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 closed pull request #7988: [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment
URL: https://github.com/apache/gravitino/pull/7988
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3190539618
> @Auxilus08 I notice you closed this issue without making the suggested change - was that intentional?
I want to explain that I locked my PR but not the issue. I think there is a mistake because I assumed @Sujal2114 was actually taking this issue on since for some reason it was assigned. I would happily take it back on if it is still open so just let me know.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3190450640
@Auxilus08 I notice you closed this issue without making the suggested change - was that intentional?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3190541748
> @Auxilus08 I notice you closed this issue without making the suggested change - was that intentional?
I’d like to clarify that I closed my PR but not the issue itself. I believe there may have been a misunderstanding, as I assumed @Sujal2114 was actively working on it given the assignment. If the issue is still available, I would be happy to resume work on it. Please let me know if that would be helpful.
@justinmclean
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#discussion_r2265692180
##########
core/src/main/java/org/apache/gravitino/StringIdentifier.java:
##########
@@ -219,9 +219,9 @@ public static String removeIdFromComment(String comment) {
}
if (indexOf != -1) {
- return comment.substring(0, indexOf);
+ return comment.substring(0, indexOf).trim();
}
}
- return comment;
+ return comment.trim();
Review Comment:
This would change the comment even if it didn't have an identifier in it, I'm not sure we want to do that.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3190546608
Sounds good, thank you! I’ll wait for your confirmation before proceeding
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3174346370
For comments without identifiers, we should preserve them exactly as they are.
Thanks for the review. I'll revert that change
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#issuecomment-3190543676
Yes, right you are. I'll ping @Sujal2114 and see if he is still working on it.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#7974] fix: trim trailing spaces in StringIdentifier.removeIdFromComment [gravitino]
Posted by "Auxilus08 (via GitHub)" <gi...@apache.org>.
Auxilus08 commented on code in PR #7988:
URL: https://github.com/apache/gravitino/pull/7988#discussion_r2266416861
##########
core/src/main/java/org/apache/gravitino/StringIdentifier.java:
##########
@@ -219,9 +219,9 @@ public static String removeIdFromComment(String comment) {
}
if (indexOf != -1) {
- return comment.substring(0, indexOf);
+ return comment.substring(0, indexOf).trim();
}
}
- return comment;
+ return comment.trim();
Review Comment:
For comments without identifiers, we should preserve them exactly as they are.
Thanks for the review. I'll revert that change
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org