From 2222e08e986a6d2a2d45ba619a62df8520349606 Mon Sep 17 00:00:00 2001 From: KyoUK4n <1337554967@qq.com> Date: Mon, 27 May 2024 17:58:39 +0800 Subject: [PATCH] Ensure HttpClient#reactorNettyVersion() does not throw NullPointException when loaded through java agent under JDK 1.8 (#3266) --- .../main/java/reactor/netty/http/client/HttpClient.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClient.java b/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClient.java index dd5b52436c..626d15dbff 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClient.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClient.java @@ -1596,9 +1596,11 @@ static boolean isCompressing(HttpHeaders h) { } static String reactorNettyVersion() { - return Optional.ofNullable(HttpClient.class.getPackage() - .getImplementationVersion()) - .orElse("dev"); + Package pac = HttpClient.class.getPackage(); + if (pac == null) { + return "dev"; + } + return Optional.ofNullable(pac.getImplementationVersion()).orElse("dev"); } static final Logger log = Loggers.getLogger(HttpClient.class);