diff --git a/source/org/jivesoftware/smackx/packet/DelayInformation.java b/source/org/jivesoftware/smackx/packet/DelayInformation.java index e9e90331a..c04409b3a 100644 --- a/source/org/jivesoftware/smackx/packet/DelayInformation.java +++ b/source/org/jivesoftware/smackx/packet/DelayInformation.java @@ -127,7 +127,11 @@ public class DelayInformation implements PacketExtension { StringBuffer buf = new StringBuffer(); buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( "\""); - buf.append(" stamp=\"").append(UTC_FORMAT.format(stamp)).append("\""); + buf.append(" stamp=\""); + synchronized (UTC_FORMAT) { + buf.append(UTC_FORMAT.format(stamp)); + } + buf.append("\""); if (from != null && from.length() > 0) { buf.append(" from=\"").append(from).append("\""); } diff --git a/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java b/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java index 2065af6fe..28bab2367 100644 --- a/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java +++ b/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java @@ -48,13 +48,17 @@ public class DelayInformationProvider implements PacketExtensionProvider { public PacketExtension parseExtension(XmlPullParser parser) throws Exception { Date stamp = null; try { - stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp")); + synchronized (DelayInformation.UTC_FORMAT) { + stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp")); + } } catch (ParseException e) { // Try again but assuming that the date follows JEP-82 format // (Jabber Date and Time Profiles) try { - stamp = DelayInformation.NEW_UTC_FORMAT - .parse(parser.getAttributeValue("", "stamp")); + synchronized (DelayInformation.NEW_UTC_FORMAT) { + stamp = DelayInformation.NEW_UTC_FORMAT + .parse(parser.getAttributeValue("", "stamp")); + } } catch (ParseException e1) { // Last attempt. Try parsing the date assuming that it does not include milliseconds SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");