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/branches/4.5.x@1713429 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2015-11-09 13:18:30 +00:00
parent 09cefc2b89
commit 549c26f958
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<SoftReference<Map<String, SimpleDateFormat>>>();
/**
* 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<String, SimpleDateFormat>();
THREADLOCAL_FORMATS.set(