From 51dd3db7c3788b91df62f87be1fae6c3b5cb67b5 Mon Sep 17 00:00:00 2001 From: nkorange Date: Mon, 1 Apr 2019 14:31:02 +0800 Subject: [PATCH] #502 Fix client beat bug --- .../com/alibaba/nacos/naming/controllers/ApiController.java | 2 ++ .../main/java/com/alibaba/nacos/naming/web/DistroFilter.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ApiController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ApiController.java index 010d2966d..a9da7b0bb 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/ApiController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/ApiController.java @@ -24,6 +24,7 @@ import com.alibaba.nacos.naming.core.DistroMapper; import com.alibaba.nacos.naming.core.ServiceManager; import com.alibaba.nacos.naming.misc.UtilsAndCommons; import com.alibaba.nacos.naming.push.ClientInfo; +import com.alibaba.nacos.naming.web.CanDistro; import com.alibaba.nacos.naming.web.OverrideParameterRequestWrapper; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -138,6 +139,7 @@ public class ApiController extends InstanceController { agent, clusters, clientIP, udpPort, env, isCheck, app, tenant, healthyOnly); } + @CanDistro @RequestMapping("/clientBeat") public JSONObject clientBeat(HttpServletRequest request) throws Exception { OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(request); diff --git a/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java b/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java index 485b9055f..aec660cdd 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/web/DistroFilter.java @@ -68,6 +68,10 @@ public class DistroFilter implements Filter { try { String path = new URI(req.getRequestURI()).getPath(); String serviceName = req.getParameter(CommonParams.SERVICE_NAME); + // For client under 0.8.0: + if (StringUtils.isBlank(serviceName)) { + serviceName = req.getParameter("dom"); + } Method method = filterBase.getMethod(req.getMethod(), path); if (method == null) {