You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/07/13 05:02:51 UTC
[incubator-skywalking] branch fix-sync created (now f31d32e)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a change to branch fix-sync
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git.
at f31d32e [Agent] Apache http client plugin bug (#1448)
This branch includes the following new commits:
new f31d32e [Agent] Apache http client plugin bug (#1448)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-skywalking] 01/01: [Agent] Apache http client plugin bug
(#1448)
Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch fix-sync
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
commit f31d32e28340b3b9ce6f110d0431b148eb15a4ef
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Fri Jul 13 12:51:41 2018 +0800
[Agent] Apache http client plugin bug (#1448)
* #1447
Fixed the after method interceptor for the apache http client NPE error when the response is null cause by the doExecute method throw a exception.
---
.../v4/HttpClientExecuteInterceptor.java | 40 +++++++++-------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
index 3688e39..5d2cf29 100644
--- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
@@ -18,23 +18,14 @@
package org.apache.skywalking.apm.plugin.httpClient.v4;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.skywalking.apm.agent.core.context.CarrierItem;
-import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.context.tag.Tags;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-
import java.lang.reflect.Method;
import java.net.URL;
+import org.apache.http.*;
+import org.apache.skywalking.apm.agent.core.context.*;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.*;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.*;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterceptor {
@@ -73,16 +64,19 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
return ret;
}
- HttpResponse response = (HttpResponse)ret;
- StatusLine responseStatusLine = response.getStatusLine();
- if (responseStatusLine != null) {
- int statusCode = responseStatusLine.getStatusCode();
- AbstractSpan span = ContextManager.activeSpan();
- if (statusCode >= 400) {
- span.errorOccurred();
- Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
+ if (ret != null) {
+ HttpResponse response = (HttpResponse)ret;
+ StatusLine responseStatusLine = response.getStatusLine();
+ if (responseStatusLine != null) {
+ int statusCode = responseStatusLine.getStatusCode();
+ AbstractSpan span = ContextManager.activeSpan();
+ if (statusCode >= 400) {
+ span.errorOccurred();
+ Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
+ }
}
}
+
ContextManager.stopSpan();
return ret;
}