### Question:
MethodUtil { public static String resolveMethodName(Method method) { if (method == null) { throw new IllegalArgumentException("Null method"); } String methodName = methodNameMap.get(method); if (methodName == null) { synchronized (LOCK) { methodName = methodNameMap.get(method); if (methodName == null) { StringBuilder sb = new StringBuilder(); String className = method.getDeclaringClass().getName(); String name = method.getName(); Class<?>[] params = method.getParameterTypes(); sb.append(className).append(":").append(name); sb.append("("); int paramPos = 0; for (Class<?> clazz : params) { sb.append(clazz.getCanonicalName()); if (++paramPos < params.length) { sb.append(","); } } sb.append(")"); methodName = sb.toString(); methodNameMap.put(method, methodName); } } } return methodName; }  static String resolveMethodName(Method method);  }### Answer:
@Test public void testResolveMethodName() { Method fooMethod = null; for (Method m : GoodClass.class.getMethods()) { if (m.getName().contains("foo")) { fooMethod = m; break; } } assertNotNull(fooMethod); assertEquals("com.alibaba.csp.sentinel.util.MethodUtilTest$GoodClass:foo(long[],java.lang.String,java.lang.Integer[])", MethodUtil.resolveMethodName(fooMethod)); Method bazMethod = null; for (Method m : GoodClass.class.getMethods()) { if (m.getName().contains("baz")) { bazMethod = m; break; } } assertNotNull(bazMethod); assertEquals("com.alibaba.csp.sentinel.util.MethodUtilTest$GoodClass:baz(double)", MethodUtil.resolveMethodName(bazMethod)); }
@Test(expected = IllegalArgumentException.class) public void testResolveNullMethod() { MethodUtil.resolveMethodName(null); }