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 2023/09/14 05:36:34 UTC

[skywalking-java] branch main updated: Fix an error status bug in the httpasyncclient plugin (#608)

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 6f80861657 Fix an error status bug in the httpasyncclient plugin (#608)
6f80861657 is described below

commit 6f808616578df3079cf2ddd93f3ffd848a9d97ba
Author: w2dp <w2...@qq.com>
AuthorDate: Thu Sep 14 13:36:29 2023 +0800

    Fix an error status bug in the httpasyncclient plugin (#608)
    
    Co-authored-by: 刘颖 <li...@51shebao.com>
---
 CHANGES.md                                                              | 1 +
 .../httpasyncclient/v4/wrapper/HttpAsyncResponseConsumerWrapper.java    | 2 +-
 .../apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java   | 1 +
 test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml | 2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index cb5ac457a8..87c8ea24be 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,7 @@ Release Notes.
 * Fix hbase onConstruct NPE in the file configuration scenario
 * Fix the issue of createSpan failure caused by invalid request URL in HttpClient 4.x/5.x plugin
 * Optimize ElasticSearch 6.x 7.x plugin compatibility
+* Fix an issue with the httpasyncclient component where the isError state is incorrect.
 
 #### Documentation
 
diff --git a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/wrapper/HttpAsyncResponseConsumerWrapper.java b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/wrapper/HttpAsyncResponseConsumerWrapper.java
index b03ad6b80d..bc0318c644 100644
--- a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/wrapper/HttpAsyncResponseConsumerWrapper.java
+++ b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/wrapper/HttpAsyncResponseConsumerWrapper.java
@@ -46,7 +46,7 @@ public class HttpAsyncResponseConsumerWrapper<T> implements HttpAsyncResponseCon
     public void responseReceived(HttpResponse response) throws IOException, HttpException {
         if (ContextManager.isActive()) {
             int statusCode = response.getStatusLine().getStatusCode();
-            AbstractSpan span = ContextManager.activeSpan().errorOccurred();
+            AbstractSpan span = ContextManager.activeSpan();
             Tags.HTTP_RESPONSE_STATUS_CODE.set(span, statusCode);
             if (statusCode >= 400) {
                 span.errorOccurred();
diff --git a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java
index 0c334eea11..f99d63bf1c 100644
--- a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java
@@ -348,6 +348,7 @@ public class HttpAsyncClientInterceptorTest {
         assertThat(tags.get(0).getValue(), is("http://localhost:8081/original/test"));
         assertThat(tags.get(1).getValue(), is("GET"));
         assertThat(tags.get(2).getValue(), is("a=1&b=test"));
+        assertThat(span.transform().getIsError(), is(false));
         assertThat(span.isExit(), is(true));
     }
 
diff --git a/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml b/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml
index f41a912821..b26bbd8927 100644
--- a/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml
@@ -60,7 +60,7 @@ segmentItems:
       startTime: nq 0
       endTime: nq 0
       componentId: 26
-      isError: true
+      isError: false
       spanType: Exit
       peer: 127.0.0.1:8080
       tags: