db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kazu Nambo (JIRA)" <j...@apache.org>
Subject [jira] Created: (TORQUE-124) Thread safety problem in JndiDataSourceFactory
Date Tue, 20 Oct 2009 09:51:59 GMT
Thread safety problem in JndiDataSourceFactory
----------------------------------------------

                 Key: TORQUE-124
                 URL: https://issues.apache.org/jira/browse/TORQUE-124
             Project: Torque
          Issue Type: Bug
          Components: Runtime
    Affects Versions: 3.3
            Reporter: Kazu Nambo
            Priority: Minor


javax.naming.InitialContext is not thread safe.
  http://java.sun.com/j2se/1.5.0/docs/api/javax/naming/InitialContext.html
    Threads that need to access a single InitialContext instance concurrently should synchronize

    amongst themselves and provide the necessary locking.

In JndiDataSourceFactory#getDataSource, InitialContext #lookup is called without synchronization.
This can be potential thread safe problems under the high load systems.

    public DataSource getDataSource() throws TorqueException
    {
        long time = System.currentTimeMillis();

        if (ds == null || time - lastLookup > ttl)
        {
            try
            {
                ds = ((DataSource) ctx.lookup(path));
                lastLookup = time;
            }
            catch (Exception e)
            {
                throw new TorqueException(e);
            }
        }

        return ds;
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message