jbarberan / beanio

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

DateTypeHandlerSupport not thread-safe #131

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create multiple Unmarshallers (one per thread) from the same StreamFactory
2. Unmarshall records with a date in each of the threads

What is the expected output? What do you see instead?
All records get unmarshalled correctely. Instead, Exceptions get thrown.

What version of BeanIO are you using? What JDK version?
BeanIO 2.1.0

Please provide any additional information below.
While the documentation claims that "All included BeanIO type handlers are 
thread safe", DateTypeHandlerSupport potentially uses the same SimpleDateFormat 
for multiple Unmarshaller instances. Since SimpleDateFormat is not thread-safe 
this causes the behaviour as shown. Switching to a custom TypeHandler that uses 
a thread-local SimpleDateFormat solves the problem.

Original issue reported on code.google.com by gyr...@gmail.com on 24 Mar 2015 at 12:58

GoogleCodeExporter commented 8 years ago
Same behaviour when using beanIO in a camel route.

Strange exceptions that trace back to SimpleDateFormat not being thread safe.

Original comment by pluim...@gmail.com on 27 Apr 2015 at 12:38