You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/07/09 06:33:58 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1876: [SCB-2036] fix memory leak when router pass header

liubao68 commented on a change in pull request #1876:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1876#discussion_r451993249



##########
File path: handlers/handler-router/src/main/java/org/apache/servicecomb/router/custom/RouterInvokeFilter.java
##########
@@ -68,67 +63,34 @@ public boolean enabled() {
   @Override
   public Response afterReceiveRequest(Invocation invocation,
       HttpServletRequestEx httpServletRequestEx) {
-    if (!isHaveHeadersRule()) {
+    if (!RouterRuleCache.isServerContainRule(invocation.getMicroserviceName())) {
       return null;
     }
-    if (!RouterRuleCache.isServerContainRule(invocation.getMicroserviceName())) {
+    List<String> headerRules = loadHeaders();
+    if (headerRules == null) {
       return null;
     }
-    if (loadHeaders()) {
-      Map<String, String> headerMap = getHeaderMap(httpServletRequestEx);
-      try {
-        invocation.addContext(ROUTER_HEADER, JsonUtils.OBJ_MAPPER.writeValueAsString(headerMap));
-      } catch (JsonProcessingException e) {
-        LOGGER.error("canary context serialization failed");
-      }
+    Map<String, String> headerMap = getHeaderMap(httpServletRequestEx, headerRules);
+    try {
+      invocation.addContext(ROUTER_HEADER, JsonUtils.OBJ_MAPPER.writeValueAsString(headerMap));
+    } catch (JsonProcessingException e) {
+      LOGGER.error("router context serialization failed");
     }
     return null;

Review comment:
       This modification is not good. Try find the root cause and fixed the condition why memory leak and do not modifify the logic of dynamicy config cache. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org