Synchronize access on DateFormat.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / GetTimesAjaxPage.java
index 1711a5b..f6bc05d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - GetTimesAjaxPage.java - Copyright © 2010–2011 David Roden
+ * Sone - GetTimesAjaxPage.java - Copyright © 2010–2012 David Roden
  *
  * This program is free software: you can redistribute it and/or modify it under
  * the terms of the GNU General Public License as published by the Free Software
@@ -22,7 +22,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Reply;
+import net.pterodactylus.sone.data.PostReply;
 import net.pterodactylus.sone.web.WebInterface;
 import net.pterodactylus.sone.web.page.FreenetRequest;
 import net.pterodactylus.util.json.JsonObject;
@@ -66,7 +66,9 @@ public class GetTimesAjaxPage extends JsonPage {
                                Time time = getTime(post.getTime());
                                postTime.put("timeText", time.getText());
                                postTime.put("refreshTime", time.getRefresh() / Time.SECOND);
-                               postTime.put("tooltip", dateFormat.format(new Date(post.getTime())));
+                               synchronized (dateFormat) {
+                                       postTime.put("tooltip", dateFormat.format(new Date(post.getTime())));
+                               }
                                postTimes.put(id, postTime);
                        }
                }
@@ -75,7 +77,7 @@ public class GetTimesAjaxPage extends JsonPage {
                if (allIds.length() > 0) {
                        String[] ids = allIds.split(",");
                        for (String id : ids) {
-                               Reply reply = webInterface.getCore().getReply(id, false);
+                               PostReply reply = webInterface.getCore().getReply(id, false);
                                if (reply == null) {
                                        continue;
                                }
@@ -83,7 +85,9 @@ public class GetTimesAjaxPage extends JsonPage {
                                Time time = getTime(reply.getTime());
                                replyTime.put("timeText", time.getText());
                                replyTime.put("refreshTime", time.getRefresh() / Time.SECOND);
-                               replyTime.put("tooltip", dateFormat.format(new Date(reply.getTime())));
+                               synchronized (dateFormat) {
+                                       replyTime.put("tooltip", dateFormat.format(new Date(reply.getTime())));
+                               }
                                replyTimes.put(id, replyTime);
                        }
                }