FYI: java.sql.Timestamp thread-safety fix

Bryce McKinlay bryce@mckinlay.net.nz
Wed Aug 4 18:01:00 GMT 2004


Access to java.util.DateFormat must be synchronized. I'm checking this in.

Regards

Bryce


2004-08-02  Bryce McKinlay  <mckinlay@redhat.com>

    * java/sql/Timestamp.java (valueOf): Synchronize access to dateFormat.

Index: java/sql/Timestamp.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/sql/Timestamp.java,v
retrieving revision 1.10
diff -u -r1.10 Timestamp.java
--- java/sql/Timestamp.java    15 Jul 2004 22:14:45 -0000    1.10
+++ java/sql/Timestamp.java    3 Aug 2004 00:17:07 -0000
@@ -99,7 +99,11 @@
 
     try
       {
-    java.util.Date d = (java.util.Date) dateFormat.parseObject(str);
+        java.util.Date d;
+        synchronized (dateFormat)
+      {
+        d = (java.util.Date) dateFormat.parseObject(str);
+      }
 
     if (d == null)
       throw new IllegalArgumentException(str);



More information about the Java-patches mailing list