You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2002/07/24 00:28:45 UTC
DO NOT REPLY [Bug 11106] New: -
CalendarDeserializer is not thread safe
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11106>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11106
CalendarDeserializer is not thread safe
Summary: CalendarDeserializer is not thread safe
Product: Axis
Version: current (nightly)
Platform: All
OS/Version: All
Status: NEW
Severity: Major
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@xml.apache.org
ReportedBy: aaron.thompson@trilogy.com
When using an Axis service which takes a Calendar parameter under load, requests
fail throwing a NumberFormatException. This is thrown by the static
java.text.SimpleDateFormat (not thread safe) used to parse the dateTime string.
Two simple solutions exist: synchronize on the SimpleDateFormat object, or
create a SimpleDateFormat for each instance of CalendarDeserializer.
Synchronizing showed better performance in my tests. Patches against nightly
2002-07-23 for both fixes are included below.
Exists in all versions of Axis up to 2002-07-23 nightly, JDK 1.3.1_03-b03.
--- java/src/org/apache/axis/encoding/ser/CalendarDeserializer.java.old
2002-07-23 03:51:28.000000000 -0500
+++ java/src/org/apache/axis/encoding/ser/CalendarDeserializer.java
2002-07-23 14:53:24.000000000 -0500
@@ -124,8 +124,10 @@
// convert what we have validated so far
try {
- date = zulu.parse(source == null ? null :
- (source.substring(0,19)+".000Z") );
+ synchronized(zulu) {
+ date = zulu.parse(source == null ? null :
+ (source.substring(0,19)+".000Z") );
+ }
} catch (Exception e) {
throw new NumberFormatException(e.toString());
}
--- java/src/org/apache/axis/encoding/ser/CalendarDeserializer.java.old
2002-07-23 03:51:28.000000000 -0500
+++ java/src/org/apache/axis/encoding/ser/CalendarDeserializer.java
2002-07-23 17:24:22.000000000 -0500
@@ -73,13 +73,10 @@
*/
public class CalendarDeserializer extends SimpleDeserializer {
- private static SimpleDateFormat zulu =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- // 0123456789 0 123456789
-
- static {
- zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
+ private SimpleDateFormat zulu;
+ private static String dateFormat =
+ new String("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ // 0123456789 0 123456789
/**
* The Deserializer is constructed with the xmlType and
@@ -87,6 +84,9 @@
*/
public CalendarDeserializer(Class javaType, QName xmlType) {
super(javaType, xmlType);
+
+ zulu = new SimpleDateFormat(dateFormat);
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
}
/**