This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 9dcad4a  Fix thread leakage caused by es client connection creation 
(#6187)
9dcad4a is described below

commit 9dcad4a0b45c058d26630fda8eda2f90d10fbe6c
Author: YczYanchengzhe <[email protected]>
AuthorDate: Wed Jan 13 15:45:52 2021 +0800

    Fix thread leakage caused by es client connection creation (#6187)
---
 CHANGES.md                                                  |  2 ++
 .../v6/interceptor/RestHighLevelClientConInterceptor.java   | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 8cfd907..29be14f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -30,6 +30,8 @@ Release Notes.
 * The operation name of dubbo and dubbo-2.7.x-plugin, has been changed as the 
`groupValue/className.methodName` format
 * Fix bug that rocketmq-plugin set the wrong tag.
 * Fix duplicated `EnhancedInstance` interface added.
+* Fix thread leaks caused by the elasticsearch-6.x-plugin plugin.
+
 
 #### OAP-Backend
 * Make meter receiver support MAL.
diff --git 
a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientConInterceptor.java
 
b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientConInterceptor.java
index 392bea3..59c2452 100644
--- 
a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientConInterceptor.java
+++ 
b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/RestHighLevelClientConInterceptor.java
@@ -18,7 +18,11 @@
 
 package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
 
+import java.io.IOException;
 import java.util.List;
+
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
 import org.apache.skywalking.apm.plugin.elasticsearch.v6.RestClientEnhanceInfo;
@@ -27,6 +31,9 @@ import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
 
 public class RestHighLevelClientConInterceptor implements 
InstanceConstructorInterceptor {
+
+    private static final ILog LOGGER = 
LogManager.getLogger(RestHighLevelClientConInterceptor.class);
+
     @Override
     public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
         RestClientBuilder restClientBuilder = (RestClientBuilder) 
allArguments[0];
@@ -37,7 +44,11 @@ public class RestHighLevelClientConInterceptor implements 
InstanceConstructorInt
         for (Node node : nodeList) {
             restClientEnhanceInfo.addHttpHost(node.getHost());
         }
-
         objInst.setSkyWalkingDynamicField(restClientEnhanceInfo);
+        try {
+            restClient.close();
+        } catch (IOException e) {
+            LOGGER.error("close restClient error , error message is " + 
e.getMessage(), e);
+        }
     }
 }

Reply via email to