On 30/01/2014 23:12, sebb wrote:
> On 30 January 2014 21:54,  <ma...@apache.org> wrote:
>> Author: markt
>> Date: Thu Jan 30 21:54:56 2014
>> New Revision: 1562992
>>
>> URL: http://svn.apache.org/r1562992
>> Log:
>> Fix DBCP-369
>> Fix threading issue when using multiple instances of the 
>> SharedPoolDataSource concurrently.
>> I can't reproduce this but the issue can be seen from looking at the code.

<snip/>

>> Modified: 
>> commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/datasources/InstanceKeyObjectFactory.java
>> URL: 
>> http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/datasources/InstanceKeyObjectFactory.java?rev=1562992&r1=1562991&r2=1562992&view=diff
>> ==============================================================================
>> --- 
>> commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/datasources/InstanceKeyObjectFactory.java
>>  (original)
>> +++ 
>> commons/proper/dbcp/branches/DBCP_1_5_x_BRANCH/src/main/java/org/apache/commons/dbcp/datasources/InstanceKeyObjectFactory.java
>>  Thu Jan 30 21:54:56 2014
>> @@ -14,7 +14,6 @@
>>   * See the License for the specific language governing permissions and
>>   * limitations under the License.
>>   */
>> -
>>  package org.apache.commons.dbcp.datasources;
>>
>>  import java.io.ByteArrayInputStream;
>> @@ -23,9 +22,9 @@ import java.io.ObjectInputStream;
>>
>>  import java.util.Hashtable;
>>  import java.util.Map;
>> -import java.util.HashMap;
>>  import java.util.Iterator;
>>  import java.util.Properties;
>> +import java.util.concurrent.ConcurrentHashMap;
>>
>>  import javax.naming.Context;
>>  import javax.naming.Name;
>> @@ -39,10 +38,9 @@ import javax.naming.spi.ObjectFactory;
>>   *
>>   * @version $Revision$ $Date$
>>   */
>> -abstract class InstanceKeyObjectFactory
>> -    implements ObjectFactory
>> -{
>> -    private static final Map instanceMap = new HashMap();
>> +abstract class InstanceKeyObjectFactory implements ObjectFactory {
>> +
>> +    private static final Map instanceMap = new ConcurrentHashMap();
> 
> Does not work - HashMap allows null as a key, but ConcurrentHashMap does not.
> 
> And the key can be null - not sure whether that is a feaure of the
> unit tests or if it is allowed for regular use as well.

Every code path that adds to the Map uses a non-null key. All that was
missing (that I could see) was a null check on the remove method. I've
added that and the tests should now pass.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to