1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

refactor log information

This commit is contained in:
fangjian0423 2019-01-15 21:59:25 +08:00
parent 0db43a3a5b
commit b059e1f8e3

View File

@ -99,36 +99,41 @@ public class SentinelBeanPostProcessor implements MergedBeanDefinitionPostProces
} }
if (blockClass != void.class && StringUtils.isEmpty(blockMethod)) { if (blockClass != void.class && StringUtils.isEmpty(blockMethod)) {
logger.error( logger.error(
"{} class property exists but {}" "{} class attribute exists but {} method attribute is not exists in bean[{}]",
+ " method property is not exists in bean[{}]",
type, type, beanName); type, type, beanName);
System.exit(-1); throw new IllegalArgumentException(type + " class attribute exists but "
+ type + " method attribute is not exists in bean[" + beanName + "]");
} }
else if (blockClass == void.class && !StringUtils.isEmpty(blockMethod)) { else if (blockClass == void.class && !StringUtils.isEmpty(blockMethod)) {
logger.error( logger.error(
"{} method property exists but {} class property is not exists in bean[{}]", "{} method attribute exists but {} class attribute is not exists in bean[{}]",
type, type, beanName); type, type, beanName);
System.exit(-1); throw new IllegalArgumentException(type + " method attribute exists but "
+ type + " class attribute is not exists in bean[" + beanName + "]");
} }
Class[] args = new Class[] { HttpRequest.class, byte[].class, Class[] args = new Class[] { HttpRequest.class, byte[].class,
ClientHttpRequestExecution.class, BlockException.class }; ClientHttpRequestExecution.class, BlockException.class };
String argsStr = Arrays.toString(
Arrays.stream(args).map(clazz -> clazz.getSimpleName()).toArray());
Method foundMethod = ClassUtils.getStaticMethod(blockClass, blockMethod, args); Method foundMethod = ClassUtils.getStaticMethod(blockClass, blockMethod, args);
if (foundMethod == null) { if (foundMethod == null) {
logger.error( logger.error(
"{} method can not be found in bean[{}]. The right method signature is {}#{}{}, please check your class name, method name and arguments", "{} static method can not be found in bean[{}]. The right method signature is {}#{}{}, please check your class name, method name and arguments",
type, beanName, blockClass.getName(), blockMethod, type, beanName, blockClass.getName(), blockMethod, argsStr);
Arrays.toString(Arrays.stream(args) throw new IllegalArgumentException(type
.map(clazz -> clazz.getSimpleName()).toArray())); + " static method can not be found in bean[" + beanName
System.exit(-1); + "]. The right method signature is " + blockClass.getName() + "#"
+ blockMethod + argsStr
+ ", please check your class name, method name and arguments");
} }
if (!ClientHttpResponse.class.isAssignableFrom(foundMethod.getReturnType())) { if (!ClientHttpResponse.class.isAssignableFrom(foundMethod.getReturnType())) {
logger.error( logger.error(
"{} method return value in bean[{}] is not ClientHttpResponse: {}#{}{}", "{} method return value in bean[{}] is not ClientHttpResponse: {}#{}{}",
type, beanName, blockClass.getName(), blockMethod, type, beanName, blockClass.getName(), blockMethod, argsStr);
Arrays.toString(Arrays.stream(args) throw new IllegalArgumentException(type + " method return value in bean["
.map(clazz -> clazz.getSimpleName()).toArray())); + beanName + "] is not ClientHttpResponse: " + blockClass.getName()
System.exit(-1); + "#" + blockMethod + argsStr);
} }
if (type.equals(SentinelConstants.BLOCK_TYPE)) { if (type.equals(SentinelConstants.BLOCK_TYPE)) {
BlockClassRegistry.updateBlockHandlerFor(blockClass, blockMethod, BlockClassRegistry.updateBlockHandlerFor(blockClass, blockMethod,