HTTPCLIENT-1216: removed ThreadLocal subclass from DateUtils

Contributed by Jochen Kemnade <jochen.kemnade at eddyson.de>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1713430 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2015-11-09 13:20:47 +00:00
parent 34aba2b3a6
commit 6ab2c32970
1 changed files with 2 additions and 10 deletions

View File

@ -200,15 +200,7 @@ public final class DateUtils {
final static class DateFormatHolder {
private static final ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>
THREADLOCAL_FORMATS = new ThreadLocal<SoftReference<Map<String, SimpleDateFormat>>>() {
@Override
protected SoftReference<Map<String, SimpleDateFormat>> initialValue() {
return new SoftReference<Map<String, SimpleDateFormat>>(
new HashMap<String, SimpleDateFormat>());
}
};
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<Map<String, SimpleDateFormat>> ref = THREADLOCAL_FORMATS.get();
Map<String, SimpleDateFormat> formats = ref.get();
Map<String, SimpleDateFormat> formats = ref == null ? null : ref.get();
if (formats == null) {
formats = new HashMap<>();
THREADLOCAL_FORMATS.set(