diff --git a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/src/main/java/co/elastic/apm/agent/httpclient/v5/helper/ApacheHttpClient5ApiAdapter.java b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/src/main/java/co/elastic/apm/agent/httpclient/v5/helper/ApacheHttpClient5ApiAdapter.java index 46d63539b94..c9010cfda22 100644 --- a/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/src/main/java/co/elastic/apm/agent/httpclient/v5/helper/ApacheHttpClient5ApiAdapter.java +++ b/apm-agent-plugins/apm-apache-httpclient/apm-apache-httpclient5-plugin/src/main/java/co/elastic/apm/agent/httpclient/v5/helper/ApacheHttpClient5ApiAdapter.java @@ -70,8 +70,9 @@ public CharSequence getHostName(@Nullable HttpHost httpHost, ClassicHttpRequest } try { - return RoutingSupport.determineHost(request) - .getHostName(); + HttpHost host = RoutingSupport.determineHost(request); + return host == null ? + null : host.getHostName(); } catch (HttpException e) { logger.error("Exception while determining HostName", e);