wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r1091657 - /incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java
Date Wed, 13 Apr 2011 05:44:12 GMT
Author: lresende
Date: Wed Apr 13 05:44:11 2011
New Revision: 1091657

URL: http://svn.apache.org/viewvc?rev=1091657&view=rev
Log:
SimpleDateFormat is not thread safe so create new instance

Fixes [WINK-329]

Thanks to Mirko Friedenhagen for reporting the issue.

Modified:
    incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java

Modified: incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java
URL: http://svn.apache.org/viewvc/incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java?rev=1091657&r1=1091656&r2=1091657&view=diff
==============================================================================
--- incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java
(original)
+++ incubator/wink/branches/wink-1.1.3-incubating/wink-webdav/src/main/java/org/apache/wink/webdav/model/WebDAVModelHelper.java
Wed Apr 13 05:44:11 2011
@@ -47,15 +47,12 @@ public class WebDAVModelHelper {
     private static final DocumentBuilderFactory documentBuilderFactory;
     private static final Document               document;
     private static final String                 XML_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
//$NON-NLS-1$
-    private static final SimpleDateFormat       dateFormat;
 
     static {
         try {
             context = JAXBContext.newInstance(Propertyupdate.class.getPackage().getName());
             documentBuilderFactory = DocumentBuilderFactory.newInstance();
             document = documentBuilderFactory.newDocumentBuilder().newDocument();
-            dateFormat = new SimpleDateFormat(XML_DATE_FORMAT);
-            dateFormat.setLenient(false);
         } catch (Exception e) {
             throw new RestException(Messages.getMessage("webDAVFailSetupPropertyHelper"),
e); //$NON-NLS-1$
         }
@@ -103,7 +100,7 @@ public class WebDAVModelHelper {
             if (!(elementClass.equals(object.getClass()))) {
                 throw new RestException(Messages
                     .getMessage("webDAVIncompatibleTypeInRequest", elementName, object.getClass()
//$NON-NLS-1$
-                    .getName(), elementClass.getName()));
+                        .getName(), elementClass.getName()));
             }
             return (T)object;
         } catch (JAXBException e) {
@@ -199,10 +196,14 @@ public class WebDAVModelHelper {
     }
 
     public static String convertDateToXMLDate(Date date) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(XML_DATE_FORMAT);
+        dateFormat.setLenient(false);
         return dateFormat.format(date);
     }
 
     public static Date convertXMLDateToDate(String date) throws ParseException {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(XML_DATE_FORMAT);
+        dateFormat.setLenient(false);
         return dateFormat.parse(date);
     }
 



Mime
View raw message