[ https://issues.apache.org/jira/browse/CLOUDSTACK-10225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16346447#comment-16346447 ]
ASF GitHub Bot commented on CLOUDSTACK-10225: --------------------------------------------- DaanHoogland closed pull request #2431: CLOUDSTACK-10225: Deprecate StringUtils in favor of Apache Commons URL: https://github.com/apache/cloudstack/pull/2431 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/utils/src/main/java/com/cloud/utils/StringUtils.java b/utils/src/main/java/com/cloud/utils/StringUtils.java index 6ada2ad60bd..aed6cef6217 100644 --- a/utils/src/main/java/com/cloud/utils/StringUtils.java +++ b/utils/src/main/java/com/cloud/utils/StringUtils.java @@ -30,8 +30,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.owasp.esapi.StringUtilities; - public class StringUtils { private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; @@ -78,12 +76,13 @@ public static String join(final String delimiter, final Object... components) { return org.apache.commons.lang.StringUtils.join(components, delimiter); } + /** + * @deprecated + * Please use org.apache.commons.lang.StringUtils.isNotBlank() as a replacement + */ + @Deprecated public static boolean isNotBlank(final String str) { - if (str != null && str.trim().length() > 0) { - return true; - } - - return false; + return org.apache.commons.lang.StringUtils.isNotBlank(str); } public static String cleanupTags(String tags) { @@ -256,24 +255,6 @@ public static boolean areTagsEqual(final String tags1, final String tags2) { return lstTags1.containsAll(lstTags2) && lstTags2.containsAll(lstTags1); } - public static String stripControlCharacters(final String s) { - return StringUtilities.stripControls(s); - } - - public static int formatForOutput(final String text, final int start, final int columns, final char separator) { - if (start >= text.length()) { - return -1; - } - - int end = start + columns; - if (end > text.length()) { - end = text.length(); - } - final String searchable = text.substring(start, end); - final int found = searchable.lastIndexOf(separator); - return found > 0 ? found : end - start; - } - public static Map<String, String> stringToMap(final String s) { final Map<String, String> map = new HashMap<String, String>(); final String[] elements = s.split(";"); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Deprecate com.cloud.utils.StringUtils > ------------------------------------- > > Key: CLOUDSTACK-10225 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10225 > Project: CloudStack > Issue Type: Improvement > Security Level: Public(Anyone can view this level - this is the > default.) > Reporter: Wido den Hollander > Priority: Major > > com.cloud.utils.StringUtils contains a lot of methods which can be deprecated > in favor of Apache Commons. > We should try to use Apache Commons where possible and reduce our code > footprint. -- This message was sent by Atlassian JIRA (v7.6.3#76005)