TheProjecter / sardine

Automatically exported from code.google.com/p/sardine
0 stars 0 forks source link

SimpleDateFormat is not thread safe #106

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Multiple threads getting metainfo from the same dav resource will sometimes 
give inconsistent dates because the SimpleDateFormat is failing some times, ie. 
not thread safe.

What is the expected output? What do you see instead?
Same date for the same dav resource.

What version of the product are you using?
Latest svn revision.

On what operating system?
Tested on Ubuntu 10.04 and Windows 2008.

What webdav server are you hitting?
Sharepoint 2010.

What is in the server error logs?
No errors.

Please provide any additional information below (including code examples
and full stack traces with line numbers in them.

Most of the times it will give the right date but sometimes it will fail and 
give exceptions like:
java.text.ParseException: Unparseable date: "2011-09-02T09:37:03Z"
    at java.text.DateFormat.parse(DateFormat.java:337)
    at com.googlecode.sardine.util.SardineUtil.parseDate(SardineUtil.java:127)
    at com.googlecode.sardine.DavResource.<init>(DavResource.java:102)
    at com.googlecode.sardine.impl.SardineImpl.list(SardineImpl.java:342)
    at pt.maisis.oobian.repositoryaccess.sharepoint.SharepointResourceAccessImpl.initDAVResource(SharepointResourceAccessImpl.java:95)
    at pt.maisis.oobian.repositoryaccess.sharepoint.SharepointResourceAccessImpl.<init>(SharepointResourceAccessImpl.java:60)
    at maisis.oobian.repositoryaccess.sharepoint.Tests$Consumer.run(Tests.java:90)
    at java.lang.Thread.run(Thread.java:662)
java.text.ParseException: Unparseable date: "2011-09-02T09:37:03Z"

A quick and dirty solution is to put the synchronized keyword on the parseDate 
method.

Original issue reported on code.google.com by pedro.a3...@gmail.com on 26 Sep 2011 at 9:02

GoogleCodeExporter commented 9 years ago
In r302.

Original comment by dkocher@sudo.ch on 26 Sep 2011 at 1:21