未验证 提交 9dcad4a0 编写于 作者: Y YczYanchengzhe 提交者: GitHub

Fix thread leakage caused by es client connection creation (#6187)

上级 d299ce03
......@@ -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.
......
......@@ -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);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册