You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/07/10 06:41:18 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2036] fix
memory leak when router pass header
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 44ad6c0 [SCB-2036] fix memory leak when router pass header
44ad6c0 is described below
commit 44ad6c0347a1e2f299a6c4932935b4a433c11943
Author: GuoYL <gy...@gmail.com>
AuthorDate: Thu Jul 9 11:30:22 2020 +0800
[SCB-2036] fix memory leak when router pass header
---
.../org/apache/servicecomb/router/cache/RouterRuleCache.java | 9 ++-------
.../org/apache/servicecomb/router/custom/RouterInvokeFilter.java | 7 ++-----
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/cache/RouterRuleCache.java b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/cache/RouterRuleCache.java
index 7409b5e..0136b08 100644
--- a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/cache/RouterRuleCache.java
+++ b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/cache/RouterRuleCache.java
@@ -21,16 +21,14 @@ import com.google.common.collect.Interners;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.config.DynamicStringProperty;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.servicecomb.router.model.PolicyRuleItem;
import org.apache.servicecomb.router.model.ServiceInfoCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;
/**
@@ -106,10 +104,7 @@ public class RouterRuleCache {
public static boolean isServerContainRule(String targetServiceName) {
DynamicStringProperty lookFor = DynamicPropertyFactory.getInstance()
.getStringProperty(String.format(ROUTE_RULE, targetServiceName), null);
- if (StringUtils.isEmpty(lookFor.get())) {
- return false;
- }
- return true;
+ return !StringUtils.isEmpty(lookFor.get());
}
public static ConcurrentHashMap<String, ServiceInfoCache> getServiceInfoCacheMap() {
diff --git a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
index 053f0de..97858a9 100644
--- a/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
+++ b/handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
@@ -30,7 +30,7 @@ import org.apache.servicecomb.swagger.invocation.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -109,10 +109,7 @@ public class RouterInvokeFilter implements HttpServerFilter {
private boolean isHaveHeadersRule() {
DynamicStringProperty headerStr = DynamicPropertyFactory.getInstance()
.getStringProperty(SERVICECOMB_ROUTER_HEADER, null);
- if (StringUtils.isEmpty(headerStr)) {
- return false;
- }
- return true;
+ return !StringUtils.isEmpty(headerStr.get());
}
private boolean addAllHeaders(String str) {