From bc61b86d3209de3be933798a98ccefe05819db96 Mon Sep 17 00:00:00 2001 From: wangyadong Date: Mon, 14 Aug 2023 17:12:23 +0800 Subject: [PATCH 1/2] fix client-http : fix build error apiPath when method without annotation ShenyuSpringMvcClient. --- .../springmvc/init/SpringMvcClientEventListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java index 78f906342641..e50c91c83ccb 100644 --- a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java @@ -172,11 +172,11 @@ protected void handleMethod(final Object bean, final Class clazz, final Method method, final String superPath) { final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class); ShenyuSpringMvcClient methodShenyuClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuSpringMvcClient.class); - methodShenyuClient = Objects.isNull(methodShenyuClient) ? beanShenyuClient : methodShenyuClient; + ShenyuSpringMvcClient shenyuClient = Objects.isNull(methodShenyuClient) ? beanShenyuClient : methodShenyuClient; // the result of ReflectionUtils#getUniqueDeclaredMethods contains method such as hashCode, wait, toSting // add Objects.nonNull(requestMapping) to make sure not register wrong method - if (Objects.nonNull(methodShenyuClient) && Objects.nonNull(requestMapping)) { - final MetaDataRegisterDTO metaData = buildMetaDataDTO(bean, methodShenyuClient, + if (Objects.nonNull(shenyuClient) &&Objects.nonNull(requestMapping)) { + final MetaDataRegisterDTO metaData = buildMetaDataDTO(bean, shenyuClient, buildApiPath(method, superPath, methodShenyuClient), clazz, method); getPublisher().publishEvent(metaData); getMetaDataMap().put(method, metaData); @@ -187,7 +187,7 @@ protected void handleMethod(final Object bean, final Class clazz, protected String buildApiPath(final Method method, final String superPath, @NonNull final ShenyuSpringMvcClient methodShenyuClient) { String contextPath = getContextPath(); - if (StringUtils.isNotBlank(methodShenyuClient.path())) { + if (Objects.nonNull(methodShenyuClient) && StringUtils.isNotBlank(methodShenyuClient.path())) { return pathJoin(contextPath, superPath, methodShenyuClient.path()); } final String path = getPathByMethod(method); From db00e8a4579acb06331b3c1643e8b1078c05612c Mon Sep 17 00:00:00 2001 From: wangyadong Date: Mon, 14 Aug 2023 17:54:30 +0800 Subject: [PATCH 2/2] fix client-http : fix build error apiPath when method without annotation ShenyuSpringMvcClient. --- .../client/springmvc/init/SpringMvcClientEventListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java index e50c91c83ccb..871ec7fe9700 100644 --- a/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java +++ b/shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java @@ -175,7 +175,7 @@ protected void handleMethod(final Object bean, final Class clazz, ShenyuSpringMvcClient shenyuClient = Objects.isNull(methodShenyuClient) ? beanShenyuClient : methodShenyuClient; // the result of ReflectionUtils#getUniqueDeclaredMethods contains method such as hashCode, wait, toSting // add Objects.nonNull(requestMapping) to make sure not register wrong method - if (Objects.nonNull(shenyuClient) &&Objects.nonNull(requestMapping)) { + if (Objects.nonNull(shenyuClient) && Objects.nonNull(requestMapping)) { final MetaDataRegisterDTO metaData = buildMetaDataDTO(bean, shenyuClient, buildApiPath(method, superPath, methodShenyuClient), clazz, method); getPublisher().publishEvent(metaData);