Github user neykov commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/641#discussion_r30218306
--- Diff: utils/common/src/main/java/brooklyn/util/text/Strings.java ---
@@ -136,26 +150,45 @@ public static String removeFromEnd(String string,
String ...suffixes) {
return string;
}
- /** as removeFromEnd, but repeats until all such suffixes are gone */
- public static String removeAllFromEnd(String string, String
...suffixes) {
+ /**
+ * As removeFromEnd, but repeats until all such suffixes are gone
+ */
+ public static String removeAllFromEnd(String string, String...
suffixes) {
+ if (isEmpty(string)) return string;
+ int index = string.length();
boolean anotherLoopNeeded = true;
while (anotherLoopNeeded) {
if (isEmpty(string)) return string;
--- End diff --
Yeah, but now `string` isn't modified so one check should be enough. I
think that to keep the initial intent (to short circuit the loop if nothing is
left of the string) the check should be replaced with `index == 0`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---