mirror of
https://gitee.com/arthas/arthas.git
synced 2024-12-02 12:17:45 +08:00
fix imporve split methodInfo/invokeInfo. #1860
This commit is contained in:
parent
e2d5c3c445
commit
2e161d621d
@ -957,15 +957,18 @@ public abstract class StringUtils {
|
||||
return text.substring(pos + after.length());
|
||||
}
|
||||
|
||||
// print|(ILjava/util/List;)V
|
||||
public static String[] splitMethodInfo(String methodInfo) {
|
||||
int index = methodInfo.indexOf('|');
|
||||
return new String[] { methodInfo.substring(0, index), methodInfo.substring(index + 1, methodInfo.length()) };
|
||||
}
|
||||
|
||||
// demo/MathGame|primeFactors|(I)Ljava/util/List;|24
|
||||
public static String[] splitInvokeInfo(String invokeInfo) {
|
||||
int index1 = invokeInfo.indexOf('|');
|
||||
int index2 = invokeInfo.indexOf('|', index1 + 1);
|
||||
int index3 = invokeInfo.indexOf('|', index2 + 1);
|
||||
return new String[] { invokeInfo.substring(0, index1), invokeInfo.substring(index1 + 1, index2),
|
||||
invokeInfo.substring(index2 + 1, invokeInfo.length()) };
|
||||
invokeInfo.substring(index2 + 1, index3), invokeInfo.substring(index3 + 1, invokeInfo.length()) };
|
||||
}
|
||||
}
|
||||
|
@ -17,12 +17,14 @@ public class SpyImplTest {
|
||||
Assertions.assertThat(StringUtils.splitMethodInfo("a|b")).containsExactly("a", "b");
|
||||
Assertions.assertThat(StringUtils.splitMethodInfo("xxxxxxxxxx|fffffffffff")).containsExactly("xxxxxxxxxx",
|
||||
"fffffffffff");
|
||||
Assertions.assertThat(StringUtils.splitMethodInfo("print|(ILjava/util/List;)V")).containsExactly("print",
|
||||
"(ILjava/util/List;)V");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitInvokeInfo() throws Throwable {
|
||||
Assertions.assertThat(StringUtils.splitInvokeInfo("a|b|c")).containsExactly("a", "b", "c");
|
||||
Assertions.assertThat(StringUtils.splitInvokeInfo("xxxxxxxxxx|fffffffffff|yyy")).containsExactly("xxxxxxxxxx",
|
||||
"fffffffffff", "yyy");
|
||||
Assertions.assertThat(StringUtils.splitInvokeInfo("demo/MathGame|primeFactors|(I)Ljava/util/List;|24"))
|
||||
.containsExactly("demo/MathGame", "primeFactors", "(I)Ljava/util/List;", "24");
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user