jsonPost.put("sone", post.getSone().getId());
jsonPost.put("recipient", (post.getRecipient() == null) ? null : post.getRecipient().getId());
jsonPost.put("time", post.getTime());
- postTemplate.set("post", post);
StringWriter stringWriter = new StringWriter();
- try {
- postTemplate.render(stringWriter);
- } catch (TemplateException te1) {
- /* TODO - shouldn’t happen. */
- } finally {
- Closer.close(stringWriter);
+ synchronized (postTemplate) {
+ postTemplate.set("post", post);
+ try {
+ postTemplate.render(stringWriter);
+ } catch (TemplateException te1) {
+ /* TODO - shouldn’t happen. */
+ } finally {
+ Closer.close(stringWriter);
+ }
}
jsonPost.put("html", stringWriter.toString());
return jsonPost;
jsonReply.put("postId", reply.getPost().getId());
jsonReply.put("soneId", reply.getSone().getId());
jsonReply.put("time", reply.getTime());
- replyTemplate.set("reply", reply);
StringWriter stringWriter = new StringWriter();
- try {
- replyTemplate.render(stringWriter);
- } catch (TemplateException te1) {
- /* TODO - shouldn’t happen. */
- } finally {
- Closer.close(stringWriter);
+ synchronized (replyTemplate) {
+ replyTemplate.set("reply", reply);
+ try {
+ replyTemplate.render(stringWriter);
+ } catch (TemplateException te1) {
+ /* TODO - shouldn’t happen. */
+ } finally {
+ Closer.close(stringWriter);
+ }
}
return jsonReply.put("html", stringWriter.toString());
}