mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-16 12:12:06 +01:00
Fixed concurrency issue with date formatter. SMACK-111
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3180 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
38f7e5bba7
commit
d1cf9cd971
2 changed files with 12 additions and 4 deletions
|
@ -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("\"");
|
||||
}
|
||||
|
|
|
@ -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'");
|
||||
|
|
Loading…
Reference in a new issue