Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db2RdbmsSpecifics implementation is not thread-safe #23

Open
GoogleCodeExporter opened this issue Aug 5, 2015 · 5 comments
Open

Db2RdbmsSpecifics implementation is not thread-safe #23

GoogleCodeExporter opened this issue Aug 5, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

Probably,Db2RdbmsSpecifics implementation is not thread-safe. 
Because SimpleDateFormat is not thread-safe...

public class Db2RdbmsSpecifics extends RdbmsSpecifics {

        private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
                        "'TIMESTAMP('''yyyy-MM-dd HH:mm:ss.SSS''')'");

        public Db2RdbmsSpecifics() {
                super();
        }

        @Override
        public String formatParameterObject(Object object) {
                if (object instanceof Date) {
                        return DATE_FORMAT.format((Date) object);
                } 
                return super.formatParameterObject(object);
        }
}

Original issue reported on code.google.com by kazuki43zoo on 4 Oct 2014 at 1:22

@GoogleCodeExporter
Copy link
Author

Just to save me some search, is RdbmsSpecifics thread-safe? (meaning, the 
problem only comes from the DATE_FORMAT attribute, not from the returned 
SimpleDataFormat)?

Original comment by [email protected] on 6 Oct 2014 at 11:49

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

RdbmsSpecifics is thread safe because create instance of SimpleDateFormat per 
method call.
SimpleDateFormat method is not supported execution under the multithreaded 
environment.(http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat
.html#synchronization)

I does not good at English,  is ok with this answer ?

Original comment by kazuki43zoo on 6 Oct 2014 at 12:20

@GoogleCodeExporter
Copy link
Author

As one cases, FastDateFormat(Common-lang) & Joda-Time is thread-safe libraries.

Original comment by kazuki43zoo on 6 Oct 2014 at 12:36

@GoogleCodeExporter
Copy link
Author

Yes, of course, thanks, I will fix this quickly. 

Original comment by [email protected] on 7 Oct 2014 at 4:06

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 31 Jan 2015 at 11:10

  • Changed state: Started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant