diff --git a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java index 0757851ed..b89dbe1e3 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java @@ -200,15 +200,7 @@ public final class DateUtils { final static class DateFormatHolder { private static final ThreadLocal>> - THREADLOCAL_FORMATS = new ThreadLocal>>() { - - @Override - protected SoftReference> initialValue() { - return new SoftReference>( - new HashMap()); - } - - }; + THREADLOCAL_FORMATS = new ThreadLocal<>(); /** * creates a {@link SimpleDateFormat} for the requested format string. @@ -224,7 +216,7 @@ public final class DateUtils { */ public static SimpleDateFormat formatFor(final String pattern) { final SoftReference> ref = THREADLOCAL_FORMATS.get(); - Map formats = ref.get(); + Map formats = ref == null ? null : ref.get(); if (formats == null) { formats = new HashMap<>(); THREADLOCAL_FORMATS.set(