Author: dbkr
Date: 2008-04-10 20:51:11 +0000 (Thu, 10 Apr 2008)
New Revision: 19155
Modified:
trunk/apps/Freemail/src/freemail/MailHeaderFilter.java
Log:
Indeed, accesses to a simpledateformat should be synchronised, apparently
Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java
===================================================================
--- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2008-04-10
20:50:00 UTC (rev 19154)
+++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2008-04-10
20:51:11 UTC (rev 19155)
@@ -44,9 +44,6 @@
private static final SimpleDateFormat sdf;
private static final TimeZone gmt;
- // TODO: according to javadoc, SimpleDateFormat objects are not
synchronized,
- // should this be taken into account?
-
static {
sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",
Locale.US);
gmt = TimeZone.getTimeZone("GMT");
@@ -116,7 +113,9 @@
Date d = null;
try {
- d = sdf.parse(val);
+ synchronized(sdf) {
+ d = sdf.parse(val);
+ }
} catch (ParseException pe) {
// ...the compiler whinges unless we catch this
exception...
Logger.normal(this,"Warning: couldn't parse
date: "+val+" (caught exception)");
@@ -129,7 +128,11 @@
Logger.normal(this,"Warning: couldn't parse
date: "+val+" (got null)");
return null;
}
- return sdf.format(d);
+ String strDate;
+ synchronized(sdf) {
+ strDate = sdf.format(d);
+ }
+ return strDate;
} else if (name.equalsIgnoreCase("User-Agent")) {
// might as well hide this
return null;