beiwei30 closed pull request #1921: [dubbo-1920] remove commons-lang3 dependency URL: https://github.com/apache/incubator-dubbo/pull/1921
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/dependencies-bom/pom.xml b/dependencies-bom/pom.xml index b3ffedb5c9..05a0592071 100644 --- a/dependencies-bom/pom.xml +++ b/dependencies-bom/pom.xml @@ -106,7 +106,6 @@ <jcl_version>1.2</jcl_version> <log4j_version>1.2.16</log4j_version> <logback_version>1.2.2</logback_version> - <commons_lang3_version>3.4</commons_lang3_version> <embedded_redis_version>0.6</embedded_redis_version> <jaxb_version>2.2.7</jaxb_version> @@ -327,11 +326,6 @@ <artifactId>logback-classic</artifactId> <version>${logback_version}</version> </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>${commons_lang3_version}</version> - </dependency> <!-- for dubbo-rpc-webservice --> <dependency> diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java index faf349f801..ca510aec94 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java @@ -38,15 +38,306 @@ public final class StringUtils { + public static final String EMPTY = ""; + public static final int INDEX_NOT_FOUND = -1; public static final String[] EMPTY_STRING_ARRAY = new String[0]; + private static final Logger logger = LoggerFactory.getLogger(StringUtils.class); private static final Pattern KVP_PATTERN = Pattern.compile("([_.a-zA-Z0-9][-_.a-zA-Z0-9]*)[=](.*)"); //key value pair pattern. - private static final Pattern INT_PATTERN = Pattern.compile("^\\d+$"); + private static final int PAD_LIMIT = 8192; private StringUtils() { } + /** + * Gets a CharSequence length or {@code 0} if the CharSequence is + * {@code null}. + * + * @param cs + * a CharSequence or {@code null} + * @return CharSequence length or {@code 0} if the CharSequence is + * {@code null}. + */ + public static int length(final CharSequence cs) { + return cs == null ? 0 : cs.length(); + } + + /** + * <p>Repeat a String {@code repeat} times to form a + * new String.</p> + * + * <pre> + * StringUtils.repeat(null, 2) = null + * StringUtils.repeat("", 0) = "" + * StringUtils.repeat("", 2) = "" + * StringUtils.repeat("a", 3) = "aaa" + * StringUtils.repeat("ab", 2) = "abab" + * StringUtils.repeat("a", -2) = "" + * </pre> + * + * @param str the String to repeat, may be null + * @param repeat number of times to repeat str, negative treated as zero + * @return a new String consisting of the original String repeated, + * {@code null} if null String input + */ + public static String repeat(final String str, final int repeat) { + // Performance tuned for 2.0 (JDK1.4) + + if (str == null) { + return null; + } + if (repeat <= 0) { + return EMPTY; + } + final int inputLength = str.length(); + if (repeat == 1 || inputLength == 0) { + return str; + } + if (inputLength == 1 && repeat <= PAD_LIMIT) { + return repeat(str.charAt(0), repeat); + } + + final int outputLength = inputLength * repeat; + switch (inputLength) { + case 1 : + return repeat(str.charAt(0), repeat); + case 2 : + final char ch0 = str.charAt(0); + final char ch1 = str.charAt(1); + final char[] output2 = new char[outputLength]; + for (int i = repeat * 2 - 2; i >= 0; i--, i--) { + output2[i] = ch0; + output2[i + 1] = ch1; + } + return new String(output2); + default : + final StringBuilder buf = new StringBuilder(outputLength); + for (int i = 0; i < repeat; i++) { + buf.append(str); + } + return buf.toString(); + } + } + + /** + * <p>Repeat a String {@code repeat} times to form a + * new String, with a String separator injected each time. </p> + * + * <pre> + * StringUtils.repeat(null, null, 2) = null + * StringUtils.repeat(null, "x", 2) = null + * StringUtils.repeat("", null, 0) = "" + * StringUtils.repeat("", "", 2) = "" + * StringUtils.repeat("", "x", 3) = "xxx" + * StringUtils.repeat("?", ", ", 3) = "?, ?, ?" + * </pre> + * + * @param str the String to repeat, may be null + * @param separator the String to inject, may be null + * @param repeat number of times to repeat str, negative treated as zero + * @return a new String consisting of the original String repeated, + * {@code null} if null String input + * @since 2.5 + */ + public static String repeat(final String str, final String separator, final int repeat) { + if(str == null || separator == null) { + return repeat(str, repeat); + } + // given that repeat(String, int) is quite optimized, better to rely on it than try and splice this into it + final String result = repeat(str + separator, repeat); + return removeEnd(result, separator); + } + + /** + * <p>Removes a substring only if it is at the end of a source string, + * otherwise returns the source string.</p> + * + * <p>A {@code null} source string will return {@code null}. + * An empty ("") source string will return the empty string. + * A {@code null} search string will return the source string.</p> + * + * <pre> + * StringUtils.removeEnd(null, *) = null + * StringUtils.removeEnd("", *) = "" + * StringUtils.removeEnd(*, null) = * + * StringUtils.removeEnd("www.domain.com", ".com.") = "www.domain.com" + * StringUtils.removeEnd("www.domain.com", ".com") = "www.domain" + * StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com" + * StringUtils.removeEnd("abc", "") = "abc" + * </pre> + * + * @param str the source String to search, may be null + * @param remove the String to search for and remove, may be null + * @return the substring with the string removed if found, + * {@code null} if null String input + */ + public static String removeEnd(final String str, final String remove) { + if (isEmpty(str) || isEmpty(remove)) { + return str; + } + if (str.endsWith(remove)) { + return str.substring(0, str.length() - remove.length()); + } + return str; + } + + /** + * <p>Returns padding using the specified delimiter repeated + * to a given length.</p> + * + * <pre> + * StringUtils.repeat('e', 0) = "" + * StringUtils.repeat('e', 3) = "eee" + * StringUtils.repeat('e', -2) = "" + * </pre> + * + * <p>Note: this method doesn't not support padding with + * <a href="http://www.unicode.org/glossary/#supplementary_character">Unicode Supplementary Characters</a> + * as they require a pair of {@code char}s to be represented. + * If you are needing to support full I18N of your applications + * consider using {@link #repeat(String, int)} instead. + * </p> + * + * @param ch character to repeat + * @param repeat number of times to repeat char, negative treated as zero + * @return String with repeated character + * @see #repeat(String, int) + */ + public static String repeat(final char ch, final int repeat) { + final char[] buf = new char[repeat]; + for (int i = repeat - 1; i >= 0; i--) { + buf[i] = ch; + } + return new String(buf); + } + + /** + * <p>Strips any of a set of characters from the end of a String.</p> + * + * <p>A {@code null} input String returns {@code null}. + * An empty string ("") input returns the empty string.</p> + * + * <p>If the stripChars String is {@code null}, whitespace is + * stripped as defined by {@link Character#isWhitespace(char)}.</p> + * + * <pre> + * StringUtils.stripEnd(null, *) = null + * StringUtils.stripEnd("", *) = "" + * StringUtils.stripEnd("abc", "") = "abc" + * StringUtils.stripEnd("abc", null) = "abc" + * StringUtils.stripEnd(" abc", null) = " abc" + * StringUtils.stripEnd("abc ", null) = "abc" + * StringUtils.stripEnd(" abc ", null) = " abc" + * StringUtils.stripEnd(" abcyx", "xyz") = " abc" + * StringUtils.stripEnd("120.00", ".0") = "12" + * </pre> + * + * @param str the String to remove characters from, may be null + * @param stripChars the set of characters to remove, null treated as whitespace + * @return the stripped String, {@code null} if null String input + */ + public static String stripEnd(final String str, final String stripChars) { + int end; + if (str == null || (end = str.length()) == 0) { + return str; + } + + if (stripChars == null) { + while (end != 0 && Character.isWhitespace(str.charAt(end - 1))) { + end--; + } + } else if (stripChars.isEmpty()) { + return str; + } else { + while (end != 0 && stripChars.indexOf(str.charAt(end - 1)) != INDEX_NOT_FOUND) { + end--; + } + } + return str.substring(0, end); + } + + /** + * <p>Replaces all occurrences of a String within another String.</p> + * + * <p>A {@code null} reference passed to this method is a no-op.</p> + * + * <pre> + * StringUtils.replace(null, *, *) = null + * StringUtils.replace("", *, *) = "" + * StringUtils.replace("any", null, *) = "any" + * StringUtils.replace("any", *, null) = "any" + * StringUtils.replace("any", "", *) = "any" + * StringUtils.replace("aba", "a", null) = "aba" + * StringUtils.replace("aba", "a", "") = "b" + * StringUtils.replace("aba", "a", "z") = "zbz" + * </pre> + * + * @see #replace(String text, String searchString, String replacement, int max) + * @param text text to search and replace in, may be null + * @param searchString the String to search for, may be null + * @param replacement the String to replace it with, may be null + * @return the text with any replacements processed, + * {@code null} if null String input + */ + public static String replace(final String text, final String searchString, final String replacement) { + return replace(text, searchString, replacement, -1); + } + + /** + * <p>Replaces a String with another String inside a larger String, + * for the first {@code max} values of the search String.</p> + * + * <p>A {@code null} reference passed to this method is a no-op.</p> + * + * <pre> + * StringUtils.replace(null, *, *, *) = null + * StringUtils.replace("", *, *, *) = "" + * StringUtils.replace("any", null, *, *) = "any" + * StringUtils.replace("any", *, null, *) = "any" + * StringUtils.replace("any", "", *, *) = "any" + * StringUtils.replace("any", *, *, 0) = "any" + * StringUtils.replace("abaa", "a", null, -1) = "abaa" + * StringUtils.replace("abaa", "a", "", -1) = "b" + * StringUtils.replace("abaa", "a", "z", 0) = "abaa" + * StringUtils.replace("abaa", "a", "z", 1) = "zbaa" + * StringUtils.replace("abaa", "a", "z", 2) = "zbza" + * StringUtils.replace("abaa", "a", "z", -1) = "zbzz" + * </pre> + * + * @param text text to search and replace in, may be null + * @param searchString the String to search for, may be null + * @param replacement the String to replace it with, may be null + * @param max maximum number of values to replace, or {@code -1} if no maximum + * @return the text with any replacements processed, + * {@code null} if null String input + */ + public static String replace(final String text, final String searchString, final String replacement, int max) { + if (isEmpty(text) || isEmpty(searchString) || replacement == null || max == 0) { + return text; + } + int start = 0; + int end = text.indexOf(searchString, start); + if (end == INDEX_NOT_FOUND) { + return text; + } + final int replLength = searchString.length(); + int increase = replacement.length() - replLength; + increase = increase < 0 ? 0 : increase; + increase *= max < 0 ? 16 : max > 64 ? 64 : max; + final StringBuilder buf = new StringBuilder(text.length() + increase); + while (end != INDEX_NOT_FOUND) { + buf.append(text.substring(start, end)).append(replacement); + start = end + replLength; + if (--max == 0) { + break; + } + end = text.indexOf(searchString, start); + } + buf.append(text.substring(start)); + return buf.toString(); + } + public static boolean isBlank(String str) { if (str == null || str.length() == 0) return true; diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/StringUtilsTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/StringUtilsTest.java index 137efa461c..56f1a980e2 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/StringUtilsTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/StringUtilsTest.java @@ -17,6 +17,7 @@ package com.alibaba.dubbo.common.utils; import com.alibaba.dubbo.common.Constants; +import org.hamcrest.Matchers; import org.junit.Test; import java.util.ArrayList; @@ -32,9 +33,70 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; public class StringUtilsTest { + @Test + public void testLength() throws Exception { + assertThat(StringUtils.length(null), equalTo(0)); + assertThat(StringUtils.length("abc"), equalTo(3)); + } + + @Test + public void testRepeat() throws Exception { + assertThat(StringUtils.repeat(null, 2), nullValue()); + assertThat(StringUtils.repeat("", 0), equalTo("")); + assertThat(StringUtils.repeat("", 2), equalTo("")); + assertThat(StringUtils.repeat("a", 3), equalTo("aaa")); + assertThat(StringUtils.repeat("ab", 2), equalTo("abab")); + assertThat(StringUtils.repeat("a", -2), equalTo("")); + assertThat(StringUtils.repeat(null, null, 2), nullValue()); + assertThat(StringUtils.repeat(null, "x", 2), nullValue()); + assertThat(StringUtils.repeat("", null, 0), equalTo("")); + assertThat(StringUtils.repeat("", "", 2), equalTo("")); + assertThat(StringUtils.repeat("", "x", 3), equalTo("xx")); + assertThat(StringUtils.repeat("?", ", ", 3), equalTo("?, ?, ?")); + assertThat(StringUtils.repeat('e', 0), equalTo("")); + assertThat(StringUtils.repeat('e', 3), equalTo("eee")); + } + + @Test + public void testStripEnd() throws Exception { + assertThat(StringUtils.stripEnd(null, "*"), nullValue()); + assertThat(StringUtils.stripEnd("", null), equalTo("")); + assertThat(StringUtils.stripEnd("abc", ""), equalTo("abc")); + assertThat(StringUtils.stripEnd("abc", null), equalTo("abc")); + assertThat(StringUtils.stripEnd(" abc", null), equalTo(" abc")); + assertThat(StringUtils.stripEnd("abc ", null), equalTo("abc")); + assertThat(StringUtils.stripEnd(" abc ", null), equalTo(" abc")); + assertThat(StringUtils.stripEnd(" abcyx", "xyz"), equalTo(" abc")); + assertThat(StringUtils.stripEnd("120.00", ".0"), equalTo("12")); + } + + @Test + public void testReplace() throws Exception { + assertThat(StringUtils.replace(null, "*", "*"), nullValue()); + assertThat(StringUtils.replace("", "*", "*"), equalTo("")); + assertThat(StringUtils.replace("any", null, "*"), equalTo("any")); + assertThat(StringUtils.replace("any", "*", null), equalTo("any")); + assertThat(StringUtils.replace("any", "", "*"), equalTo("any")); + assertThat(StringUtils.replace("aba", "a", null), equalTo("aba")); + assertThat(StringUtils.replace("aba", "a", ""), equalTo("b")); + assertThat(StringUtils.replace("aba", "a", "z"), equalTo("zbz")); + assertThat(StringUtils.replace(null, "*", "*", 64), nullValue()); + assertThat(StringUtils.replace("", "*", "*", 64), equalTo("")); + assertThat(StringUtils.replace("any", null, "*", 64), equalTo("any")); + assertThat(StringUtils.replace("any", "*", null, 64), equalTo("any")); + assertThat(StringUtils.replace("any", "", "*", 64), equalTo("any")); + assertThat(StringUtils.replace("any", "*", "*", 0), equalTo("any")); + assertThat(StringUtils.replace("abaa", "a", null, -1), equalTo("abaa")); + assertThat(StringUtils.replace("abaa", "a", "", -1), equalTo("b")); + assertThat(StringUtils.replace("abaa", "a", "z", 0), equalTo("abaa")); + assertThat(StringUtils.replace("abaa", "a", "z", 1), equalTo("zbaa")); + assertThat(StringUtils.replace("abaa", "a", "z", 2), equalTo("zbza")); + } + @Test public void testIsBlank() throws Exception { assertTrue(StringUtils.isBlank(null)); diff --git a/dubbo-plugin/dubbo-qos/pom.xml b/dubbo-plugin/dubbo-qos/pom.xml index 2a0ca19fc6..ea1df02df9 100644 --- a/dubbo-plugin/dubbo-qos/pom.xml +++ b/dubbo-plugin/dubbo-qos/pom.xml @@ -47,9 +47,5 @@ <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> </dependencies> </project> diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/command/decoder/TelnetCommandDecoder.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/command/decoder/TelnetCommandDecoder.java index 6ffd680766..e8ff7e4bc2 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/command/decoder/TelnetCommandDecoder.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/command/decoder/TelnetCommandDecoder.java @@ -16,15 +16,15 @@ */ package com.alibaba.dubbo.qos.command.decoder; +import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.dubbo.qos.command.CommandContext; import com.alibaba.dubbo.qos.command.CommandContextFactory; -import org.apache.commons.lang3.StringUtils; public class TelnetCommandDecoder { public static final CommandContext decode(String str) { CommandContext commandContext = null; - if (StringUtils.isNotBlank(str)) { + if (!StringUtils.isBlank(str)) { String[] array = str.split("(?<![\\\\]) "); if (array.length > 0) { String name = array[0]; diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/server/handler/TelnetProcessHandler.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/server/handler/TelnetProcessHandler.java index 5da8f3027b..34cc4172af 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/server/handler/TelnetProcessHandler.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/server/handler/TelnetProcessHandler.java @@ -19,6 +19,7 @@ import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; +import com.alibaba.dubbo.common.utils.StringUtils; import com.alibaba.dubbo.qos.command.CommandContext; import com.alibaba.dubbo.qos.command.CommandExecutor; import com.alibaba.dubbo.qos.command.DefaultCommandExecutor; @@ -29,7 +30,6 @@ import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import org.apache.commons.lang3.StringUtils; /** * Telnet process handler @@ -50,7 +50,7 @@ protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Except try { String result = commandExecutor.execute(commandContext); - if (StringUtils.equals(QosConstants.CLOSE, result)) { + if (StringUtils.isEquals(QosConstants.CLOSE, result)) { ctx.writeAndFlush(getByeLabel()).addListener(ChannelFutureListener.CLOSE); } else { ctx.writeAndFlush(result + QosConstants.BR_STR + QosProcessHandler.prompt); diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TKv.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TKv.java index 5080462bb9..f61833d988 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TKv.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TKv.java @@ -16,7 +16,7 @@ */ package com.alibaba.dubbo.qos.textui; -import org.apache.commons.lang3.StringUtils; +import com.alibaba.dubbo.common.utils.StringUtils; import java.util.Scanner; diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TLadder.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TLadder.java index be70363855..ded5810b3a 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TLadder.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TLadder.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; -import static org.apache.commons.lang3.StringUtils.repeat; +import static com.alibaba.dubbo.common.utils.StringUtils.repeat; /** * Ladder diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTable.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTable.java index 7e266d5346..3add25f4fd 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTable.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTable.java @@ -16,19 +16,18 @@ */ package com.alibaba.dubbo.qos.textui; -import org.apache.commons.lang3.StringUtils; - import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; +import static com.alibaba.dubbo.common.utils.StringUtils.EMPTY; +import static com.alibaba.dubbo.common.utils.StringUtils.length; +import static com.alibaba.dubbo.common.utils.StringUtils.repeat; +import static com.alibaba.dubbo.common.utils.StringUtils.replace; import static java.lang.Math.abs; import static java.lang.Math.max; import static java.lang.String.format; -import static org.apache.commons.lang3.StringUtils.EMPTY; -import static org.apache.commons.lang3.StringUtils.length; -import static org.apache.commons.lang3.StringUtils.repeat; /** * Table @@ -189,7 +188,7 @@ private String getData(int rowIndex, ColumnDefine columnDefine) { private String getDataFormat(ColumnDefine columnDefine, int width, String data) { switch (columnDefine.align) { case MIDDLE: { - final int length = StringUtils.length(data); + final int length = length(data); final int diff = width - length; final int left = diff / 2; return repeat(" ", diff - left) + "%s" + repeat(" ", left); @@ -407,7 +406,7 @@ public int getColumnCount() { * @return the replaced string */ private static String replaceTab(String string) { - return StringUtils.replace(string, "\t", " "); + return replace(string, "\t", " "); } /** diff --git a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTree.java b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTree.java index 9766fb33b4..7220d61a87 100644 --- a/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTree.java +++ b/dubbo-plugin/dubbo-qos/src/main/java/com/alibaba/dubbo/qos/textui/TTree.java @@ -16,16 +16,15 @@ */ package com.alibaba.dubbo.qos.textui; -import org.apache.commons.lang3.StringUtils; - import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; +import static com.alibaba.dubbo.common.utils.StringUtils.EMPTY; +import static com.alibaba.dubbo.common.utils.StringUtils.length; +import static com.alibaba.dubbo.common.utils.StringUtils.repeat; import static java.lang.System.currentTimeMillis; -import static org.apache.commons.lang3.StringUtils.EMPTY; -import static org.apache.commons.lang3.StringUtils.repeat; /** * tree @@ -65,7 +64,7 @@ public void callback(int deep, boolean isLast, String prefix, Node node) { final boolean hasChild = !node.children.isEmpty(); final String stepString = isLast ? STEP_FIRST_CHAR : STEP_NORMAL_CHAR; - final int stepStringLength = StringUtils.length(stepString); + final int stepStringLength = length(stepString); treeSB.append(prefix).append(stepString); int costPrefixLength = 0; @@ -75,7 +74,7 @@ public void callback(int deep, boolean isLast, String prefix, Node node) { if (isPrintCost && !node.isRoot()) { final String costPrefix = String.format("[%s,%sms]", (node.endTimestamp - root.beginTimestamp), (node.endTimestamp - node.beginTimestamp)); - costPrefixLength = StringUtils.length(costPrefix); + costPrefixLength = length(costPrefix); treeSB.append(costPrefix); } ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org