mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +01:00
SMACK-328 Added patches to fix threading issue with usage of SimpleDateFormatter.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_2_0@12030 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
75094d0199
commit
64d36a52e3
2 changed files with 17 additions and 16 deletions
|
@ -46,8 +46,9 @@ public class QueueDetails implements PacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
private static final String DATE_FORMAT = "yyyyMMdd'T'HH:mm:ss";
|
||||
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
/**
|
||||
* The list of users in the queue.
|
||||
*/
|
||||
|
@ -124,7 +125,7 @@ public class QueueDetails implements PacketExtension {
|
|||
|
||||
if (timestamp != null) {
|
||||
buf.append("<join-time>");
|
||||
buf.append(DATE_FORMATTER.format(timestamp));
|
||||
buf.append(dateFormat.format(timestamp));
|
||||
buf.append("</join-time>");
|
||||
}
|
||||
|
||||
|
@ -139,8 +140,10 @@ public class QueueDetails implements PacketExtension {
|
|||
* Provider class for QueueDetails packet extensions.
|
||||
*/
|
||||
public static class Provider implements PacketExtensionProvider {
|
||||
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
QueueDetails queueDetails = new QueueDetails();
|
||||
|
||||
int eventType = parser.getEventType();
|
||||
|
@ -163,7 +166,7 @@ public class QueueDetails implements PacketExtension {
|
|||
eventType = parser.next();
|
||||
while ((eventType != XmlPullParser.END_TAG)
|
||||
|| (! "user".equals(parser.getName())))
|
||||
{
|
||||
{
|
||||
if ("position".equals(parser.getName())) {
|
||||
position = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
|
@ -171,23 +174,19 @@ public class QueueDetails implements PacketExtension {
|
|||
time = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if ("join-time".equals(parser.getName())) {
|
||||
joinTime = DATE_FORMATTER.parse(parser.nextText());
|
||||
joinTime = dateFormat.parse(parser.nextText());
|
||||
}
|
||||
else if( parser.getName().equals( "waitTime" ) ) {
|
||||
Date wait = DATE_FORMATTER.parse( parser.nextText() );
|
||||
System.out.println( wait );
|
||||
Date wait = dateFormat.parse(parser.nextText());
|
||||
System.out.println( wait );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
eventType = parser.next();
|
||||
|
||||
if (eventType != XmlPullParser.END_TAG) {
|
||||
// throw exception
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
queueDetails.addUser(new QueueUser(uid, position, time, joinTime));
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ public class QueueOverview implements PacketExtension {
|
|||
*/
|
||||
public static String NAMESPACE = "http://jabber.org/protocol/workgroup";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
private static final String DATE_FORMAT = "yyyyMMdd'T'HH:mm:ss";
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
private int averageWaitTime;
|
||||
private Date oldestEntry;
|
||||
|
@ -101,7 +102,7 @@ public class QueueOverview implements PacketExtension {
|
|||
buf.append("<count>").append(userCount).append("</count>");
|
||||
}
|
||||
if (oldestEntry != null) {
|
||||
buf.append("<oldest>").append(DATE_FORMATTER.format(oldestEntry)).append("</oldest>");
|
||||
buf.append("<oldest>").append(dateFormat.format(oldestEntry)).append("</oldest>");
|
||||
}
|
||||
if (averageWaitTime != -1) {
|
||||
buf.append("<time>").append(averageWaitTime).append("</time>");
|
||||
|
@ -118,7 +119,8 @@ public class QueueOverview implements PacketExtension {
|
|||
|
||||
public PacketExtension parseExtension (XmlPullParser parser) throws Exception {
|
||||
int eventType = parser.getEventType();
|
||||
QueueOverview queueOverview = new QueueOverview();
|
||||
QueueOverview queueOverview = new QueueOverview();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
if (eventType != XmlPullParser.START_TAG) {
|
||||
// throw exception
|
||||
|
@ -135,7 +137,7 @@ public class QueueOverview implements PacketExtension {
|
|||
queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText()));
|
||||
}
|
||||
else if ("oldest".equals(parser.getName())) {
|
||||
queueOverview.setOldestEntry((DATE_FORMATTER.parse(parser.nextText())));
|
||||
queueOverview.setOldestEntry((dateFormat.parse(parser.nextText())));
|
||||
}
|
||||
else if ("status".equals(parser.getName())) {
|
||||
queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText()));
|
||||
|
|
Loading…
Reference in a new issue