diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java index 35c6314317..51cfa8d04f 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DBCPDriverDataSource.java @@ -187,12 +187,14 @@ private Properties updateDBCPProperties(Properties props) { } // set some default properties for DBCP - if (hasKey(dbcpProps, "maxActive") == null) { + String maxActiveKey = hasKey(dbcpProps, "maxActive"); + if (maxActiveKey == null) { dbcpProps.setProperty("maxActive", "10"); + maxActiveKey = "maxActive"; } if (hasKey(dbcpProps, "maxIdle") == null) { // by default we set maxIdle to the same value as maxActive. - dbcpProps.setProperty("maxIdle", dbcpProps.getProperty("maxActive")); + dbcpProps.setProperty("maxIdle", dbcpProps.getProperty(maxActiveKey)); } if (hasKey(dbcpProps, "minIdle") == null) { dbcpProps.setProperty("minIdle", "0"); diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java new file mode 100644 index 0000000000..d6ba5f4cc5 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConnectionProperties.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.conf; + +import org.apache.openjpa.persistence.OpenJPAEntityManager; +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +public class TestConnectionProperties extends SingleEMFTestCase { + @Override + public void setUp() throws Exception { + super.setUp(new Object[] { "openjpa.ConnectionProperties", + "autoReconnect=true,MaxActive=10,MaxWait=6000,TestOnBorrow=true" + }); + emf.createEntityManager().close(); + } + + public void testEmWithProps() { + OpenJPAEntityManager em = emf.createEntityManager(); + em.close(); + } +} diff --git a/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml b/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml index 6bdeabbf38..ff4dd7ce01 100644 --- a/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml +++ b/openjpa-tools/openjpa-maven-plugin/src/it/sqlActionRefresh/src/main/resources/META-INF/persistence.xml @@ -20,16 +20,5 @@ org.apache.openjpa.tools.maven.testentity.TestEntity - - - -