Skip to content

Commit 237a95f

Browse files
Added npe check for null response; fixes gh-158
1 parent e1376fa commit 237a95f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-cloud-sleuth-otel/src/main/java/org/springframework/cloud/sleuth/otel/bridge/OtelHttpClientHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public void handleReceive(HttpClientResponse response, Span span) {
137137
// entirely correct here atm
138138
Context contextToEnd = Context.current().with(otelSpanWrapper.delegate);
139139
// response.getRequest() too often returns null
140-
instrumenter.end(contextToEnd, otelContext.get(REQUEST_CONTEXT_KEY), response, response.error());
140+
Throwable error = response != null ? response.error() : null;
141+
instrumenter.end(contextToEnd, otelContext.get(REQUEST_CONTEXT_KEY), response, error);
141142
}
142143

143144
}

0 commit comments

Comments
 (0)