mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +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();
|
StringBuffer buf = new StringBuffer();
|
||||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
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) {
|
if (from != null && from.length() > 0) {
|
||||||
buf.append(" from=\"").append(from).append("\"");
|
buf.append(" from=\"").append(from).append("\"");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,13 +48,17 @@ public class DelayInformationProvider implements PacketExtensionProvider {
|
||||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||||
Date stamp = null;
|
Date stamp = null;
|
||||||
try {
|
try {
|
||||||
stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp"));
|
synchronized (DelayInformation.UTC_FORMAT) {
|
||||||
|
stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp"));
|
||||||
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
// Try again but assuming that the date follows JEP-82 format
|
// Try again but assuming that the date follows JEP-82 format
|
||||||
// (Jabber Date and Time Profiles)
|
// (Jabber Date and Time Profiles)
|
||||||
try {
|
try {
|
||||||
stamp = DelayInformation.NEW_UTC_FORMAT
|
synchronized (DelayInformation.NEW_UTC_FORMAT) {
|
||||||
.parse(parser.getAttributeValue("", "stamp"));
|
stamp = DelayInformation.NEW_UTC_FORMAT
|
||||||
|
.parse(parser.getAttributeValue("", "stamp"));
|
||||||
|
}
|
||||||
} catch (ParseException e1) {
|
} catch (ParseException e1) {
|
||||||
// Last attempt. Try parsing the date assuming that it does not include milliseconds
|
// 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'");
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||||
|
|
Loading…
Reference in a new issue