@@ -45,13 +45,24 @@ public class AsyncHttpProviderUtils {
45
45
46
46
private final static String BODY_NOT_COMPUTED = "Response's body hasn't been computed by your AsyncHandler." ;
47
47
48
- private final static SimpleDateFormat [] RFC2822_LIKE_DATE_FORMATS =
49
- {
50
- new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss z" , Locale .US ),
51
- new SimpleDateFormat ("EEE, dd-MMM-yyyy HH:mm:ss z" , Locale .US ),
52
- new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss Z" , Locale .US ),
53
- new SimpleDateFormat ("EEE, dd-MMM-yyyy HH:mm:ss Z" , Locale .US ),
54
- };
48
+
49
+ protected final static ThreadLocal <SimpleDateFormat []> simpleDateFormat = new ThreadLocal <SimpleDateFormat []>() {
50
+ protected SimpleDateFormat [] initialValue () {
51
+
52
+ return new SimpleDateFormat []
53
+ {
54
+ new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss z" , Locale .US ),
55
+ new SimpleDateFormat ("EEE, dd-MMM-yyyy HH:mm:ss z" , Locale .US ),
56
+ new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss Z" , Locale .US ),
57
+ new SimpleDateFormat ("EEE, dd-MMM-yyyy HH:mm:ss Z" , Locale .US ),
58
+ };
59
+ }
60
+ };
61
+
62
+ public final static SimpleDateFormat [] get () {
63
+ return simpleDateFormat .get ();
64
+ }
65
+
55
66
56
67
//space ' '
57
68
static final byte SP = 32 ;
@@ -442,7 +453,7 @@ public static Cookie parseCookie(String value) {
442
453
443
454
private static int convertExpireField (String timestring ) throws Exception {
444
455
Exception exception = null ;
445
- for (SimpleDateFormat sdf : RFC2822_LIKE_DATE_FORMATS ) {
456
+ for (SimpleDateFormat sdf : simpleDateFormat . get () ) {
446
457
try {
447
458
long expire = sdf .parse (removeQuote (timestring .trim ())).getTime ();
448
459
return (int ) (expire - System .currentTimeMillis ()) / 1000 ;
0 commit comments