Commit 2a41d6f2 authored by Florian Schmaus's avatar Florian Schmaus Committed by flow

Use fine grained locking for Date/Time parsing until OF-609 is fixed.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13469 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1cadaacd
...@@ -95,7 +95,7 @@ public class XMPPDateTimeFormat { ...@@ -95,7 +95,7 @@ public class XMPPDateTimeFormat {
* @return * @return
* @throws ParseException * @throws ParseException
*/ */
public synchronized Date parseString(String dateString) throws ParseException { public Date parseString(String dateString) throws ParseException {
Matcher xep82WoMillisMatcher = xep80DateTimePattern.matcher(dateString); Matcher xep82WoMillisMatcher = xep80DateTimePattern.matcher(dateString);
Matcher xep82Matcher = xep80DateTimeWoMillisPattern.matcher(dateString); Matcher xep82Matcher = xep80DateTimeWoMillisPattern.matcher(dateString);
...@@ -115,15 +115,21 @@ public class XMPPDateTimeFormat { ...@@ -115,15 +115,21 @@ public class XMPPDateTimeFormat {
} }
if (xep82WoMillisMatcher.matches()) { if (xep82WoMillisMatcher.matches()) {
synchronized (dateTimeFormatWoMillies) {
return dateTimeFormatWoMillies.parse(rfc822Date); return dateTimeFormatWoMillies.parse(rfc822Date);
}
} else { } else {
synchronized (dateTimeFormat) {
return dateTimeFormat.parse(rfc822Date); return dateTimeFormat.parse(rfc822Date);
} }
}
} else { } else {
// at last try with the legacy format // at last try with the legacy format
synchronized (dateTimeFormatOld) {
return dateTimeFormatOld.parse(dateString); return dateTimeFormatOld.parse(dateString);
} }
} }
}
/** /**
* Tries to convert a given string to a Date object. * Tries to convert a given string to a Date object.
...@@ -133,9 +139,11 @@ public class XMPPDateTimeFormat { ...@@ -133,9 +139,11 @@ public class XMPPDateTimeFormat {
* @return * @return
* @throws ParseException * @throws ParseException
*/ */
public synchronized Date parseOldDate(String dateStr) throws ParseException { public Date parseOldDate(String dateStr) throws ParseException {
synchronized (dateTimeFormatOld) {
return dateTimeFormatOld.parse(dateStr); return dateTimeFormatOld.parse(dateStr);
} }
}
/** /**
* Formats a Date object to String as defined in XEP-0082. * Formats a Date object to String as defined in XEP-0082.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment