You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/04/29 04:53:20 UTC

[skywalking-java] branch main updated: Fix NPE in elasticsearch plugin (#167)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new edc69ed84 Fix NPE in elasticsearch plugin (#167)
edc69ed84 is described below

commit edc69ed8476826315208362c676e2b214eb3ae0b
Author: xzyJavaX <49...@users.noreply.github.com>
AuthorDate: Fri Apr 29 12:53:14 2022 +0800

    Fix NPE in elasticsearch plugin (#167)
---
 CHANGES.md                                                            | 1 +
 .../interceptor/AdapterActionFutureActionGetMethodsInterceptor.java   | 4 +++-
 .../interceptor/AdapterActionFutureActionGetMethodsInterceptor.java   | 4 +++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 10f0475ee..8945f8364 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -12,6 +12,7 @@ Release Notes.
 * Fix NPE in gateway plugin when the timer triggers webflux webclient call.
 * Add an optional plugin, trace-sampler-cpu-policy-plugin, which could disable trace collecting in high CPU load.
 * Change the dateformat of logs to `yyyy-MM-dd HH:mm:ss.SSS`(was `yyyy-MM-dd HH:mm:ss:SSS`).
+* Fix NPE in elasticsearch plugin.
 
 #### Documentation
 
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
index bee05a636..152238352 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v6/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
@@ -66,7 +66,9 @@ public class AdapterActionFutureActionGetMethodsInterceptor implements InstanceM
     @Override
     public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
                                       Class<?>[] argumentsTypes, Throwable t) {
-        ContextManager.activeSpan().log(t);
+        if (isTrace(objInst)) {
+            ContextManager.activeSpan().log(t);
+        }
     }
 
     private boolean isTrace(EnhancedInstance objInst) {
diff --git a/apm-sniffer/apm-sdk-plugin/elasticsearch-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v7/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/elasticsearch-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v7/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
index fb19d3483..47f0b8d10 100644
--- a/apm-sniffer/apm-sdk-plugin/elasticsearch-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v7/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/elasticsearch-7.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/elasticsearch/v7/interceptor/AdapterActionFutureActionGetMethodsInterceptor.java
@@ -67,7 +67,9 @@ public class AdapterActionFutureActionGetMethodsInterceptor implements InstanceM
     @Override
     public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
                                       Class<?>[] argumentsTypes, Throwable t) {
-        ContextManager.activeSpan().log(t);
+        if (isTrace(objInst)) {
+            ContextManager.activeSpan().log(t);
+        }
     }
 
     private boolean isTrace(EnhancedInstance objInst) {