From 30320fe2f4cadb605e15438307b7d49c543b5898 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Sun, 15 Oct 2017 13:31:13 +0200 Subject: [PATCH] Fixed NPE in case of a missing Max-Forwards header --- .../org/apache/hc/client5/http/impl/cache/CachingExecBase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java index 5117eb873..1ab84d666 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java @@ -354,7 +354,8 @@ public class CachingExecBase { return false; } - if (!"0".equals(request.getFirstHeader(HeaderConstants.MAX_FORWARDS).getValue())) { + final Header h = request.getFirstHeader(HeaderConstants.MAX_FORWARDS); + if (!"0".equals(h != null ? h.getValue() : null)) { return false; }