You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/07/29 14:30:43 UTC

[commons-dbcp] 07/07: Use current version of JaCoCo.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git

commit c419630e2342f6acc2109fb0773c55f1a96d9f67
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 29 10:30:31 2019 -0400

    Use current version of JaCoCo.
    
    - Also fix BC version.
    - Reinstate log(String) as a protected method for BC.
    - Better lvar names.
    - Javadoc "jdni" -> "JNDI".
    - Javadoc "api" -> "API".
---
 pom.xml                                            |  3 ++-
 .../org/apache/commons/dbcp2/BasicDataSource.java  | 10 ++++++--
 .../apache/commons/dbcp2/DelegatingConnection.java | 30 +++++++++++-----------
 .../dbcp2/datasources/InstanceKeyDataSource.java   | 18 ++++++-------
 .../datasources/InstanceKeyDataSourceFactory.java  |  2 +-
 .../java/org/apache/commons/dbcp2/TestJndi.java    | 12 ++++-----
 6 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6a09757..4142991 100644
--- a/pom.xml
+++ b/pom.xml
@@ -312,11 +312,12 @@
     <!-- Constant for Commons Pool version (used in multiple places) -->
     <commons.pool.version>2.7.0</commons.pool.version>
     <commons.japicmp.version>0.14.1</commons.japicmp.version>
+    <commons.jacoco.version>0.8.4</commons.jacoco.version>
     <!-- See DBCP-445 and DBCP-454 -->
     <commons.osgi.import>javax.transaction;version="1.1.0",javax.transaction.xa;version="1.1.0";partial=true;mandatory:=partial,*</commons.osgi.import>
     <commons.japicmp.ignoreMissingClasses>true</commons.japicmp.ignoreMissingClasses>
     <!-- Commons Release Plugin -->
-    <commons.bc.version>2.6.2</commons.bc.version>
+    <commons.bc.version>2.6.0</commons.bc.version>
     <commons.release.isDistModule>true</commons.release.isDistModule>
     <commons.releaseManagerName>Gary Gregory</commons.releaseManagerName>    
     <commons.releaseManagerKey>86fdc7e2a11262cb</commons.releaseManagerKey>
diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
index 6dd7320..25d5981 100644
--- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
@@ -1520,13 +1520,19 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
         }
     }
 
-    void log(final String message) {
+    protected void log(final String message) {
         if (logWriter != null) {
             logWriter.println(message);
         }
     }
 
-    void log(Throwable throwable) {
+    /**
+     * Logs the given throwable.
+     * 
+     * @param throwable the throwable.
+     * @since 2.7.0
+     */
+    protected void log(Throwable throwable) {
         if (logWriter != null) {
             throwable.printStackTrace(logWriter);
         }        
diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
index 546e6a8..fc09b23 100644
--- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
@@ -89,17 +89,17 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i
      */
     @Override
     public synchronized String toString() {
-        String s = null;
+        String str = null;
 
-        final Connection c = this.getInnermostDelegateInternal();
-        if (c != null) {
+        final Connection conn = this.getInnermostDelegateInternal();
+        if (conn != null) {
             try {
-                if (c.isClosed()) {
-                    s = "connection is closed";
+                if (conn.isClosed()) {
+                    str = "connection is closed";
                 } else {
                     final StringBuffer sb = new StringBuffer();
                     sb.append(hashCode());
-                    final DatabaseMetaData meta = c.getMetaData();
+                    final DatabaseMetaData meta = conn.getMetaData();
                     if (meta != null) {
                         sb.append(", URL=");
                         sb.append(meta.getURL());
@@ -107,7 +107,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i
                         sb.append(meta.getUserName());
                         sb.append(", ");
                         sb.append(meta.getDriverName());
-                        s = sb.toString();
+                        str = sb.toString();
                     }
                 }
             } catch (final SQLException ex) {
@@ -115,11 +115,11 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i
             }
         }
 
-        if (s == null) {
-            s = super.toString();
+        if (str == null) {
+            str = super.toString();
         }
 
-        return s;
+        return str;
     }
 
     /**
@@ -175,14 +175,14 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i
      * @return innermost delegate.
      */
     public final Connection getInnermostDelegateInternal() {
-        Connection c = connection;
-        while (c != null && c instanceof DelegatingConnection) {
-            c = ((DelegatingConnection<?>) c).getDelegateInternal();
-            if (this == c) {
+        Connection conn = connection;
+        while (conn != null && conn instanceof DelegatingConnection) {
+            conn = ((DelegatingConnection<?>) conn).getDelegateInternal();
+            if (this == conn) {
                 return null;
             }
         }
-        return c;
+        return conn;
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
index 1b070cc..13c0cab 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
@@ -98,7 +98,7 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
     /** Description */
     private String description;
 
-    /** Environment that may be used to set up a jndi initial context. */
+    /** Environment that may be used to set up a JNDI initial context. */
     private Properties jndiEnvironment;
 
     /** Login TimeOut in seconds */
@@ -520,8 +520,8 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
     }
 
     /**
-     * Gets the value of connectionPoolDataSource. This method will return null, if the backing datasource is being
-     * accessed via jndi.
+     * Gets the value of connectionPoolDataSource. This method will return null, if the backing data source is being
+     * accessed via JNDI.
      *
      * @return value of connectionPoolDataSource.
      */
@@ -530,8 +530,8 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
     }
 
     /**
-     * Sets the backend ConnectionPoolDataSource. This property should not be set if using jndi to access the
-     * datasource.
+     * Sets the backend ConnectionPoolDataSource. This property should not be set if using JNDI to access the
+     * data source.
      *
      * @param v
      *            Value to assign to connectionPoolDataSource.
@@ -549,8 +549,8 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
     }
 
     /**
-     * Gets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the datasource
-     * from a jndi service provider.
+     * Gets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the data source
+     * from a JNDI service provider.
      *
      * @return value of dataSourceName.
      */
@@ -559,8 +559,8 @@ public abstract class InstanceKeyDataSource implements DataSource, Referenceable
     }
 
     /**
-     * Sets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the datasource
-     * from a jndi service provider.
+     * Sets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the data source
+     * from a JNDI service provider.
      *
      * @param v
      *            Value to assign to dataSourceName.
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
index ee68cd7..f6ee923 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
@@ -120,7 +120,7 @@ abstract class InstanceKeyDataSourceFactory implements ObjectFactory {
             if (isCorrectClass(ref.getClassName())) {
                 final RefAddr refAddr = ref.get("instanceKey");
                 if (refAddr != null && refAddr.getContent() != null) {
-                    // object was bound to jndi via Referenceable api.
+                    // object was bound to JNDI via Referenceable API.
                     obj = instanceMap.get(refAddr.getContent());
                 } else {
                     // Tomcat JNDI creates a Reference out of server.xml
diff --git a/src/test/java/org/apache/commons/dbcp2/TestJndi.java b/src/test/java/org/apache/commons/dbcp2/TestJndi.java
index 6d5eb94..c9f5b27 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestJndi.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestJndi.java
@@ -43,12 +43,12 @@ public class TestJndi {
     protected static final String JNDI_SUBCONTEXT = "jdbc";
 
     /**
-     * the full jndi path to the data source.
+     * the full JNDI path to the data source.
      */
     protected static final String JNDI_PATH = JNDI_SUBCONTEXT + "/"
             + "jndiTestDataSource";
 
-    /** jndi context to use in tests **/
+    /** JNDI context to use in tests **/
     protected Context context = null;
 
     /**
@@ -97,7 +97,7 @@ public class TestJndi {
     }
 
     /**
-     * Binds a DataSource to the jndi and checks that we have successfully
+     * Binds a DataSource to the JNDI and checks that we have successfully
      * bound it by looking it up again.
      *
      * @throws Exception if the bind, lookup or connect fails
@@ -108,7 +108,7 @@ public class TestJndi {
     }
 
     /**
-     * Binds a DataSource into jndi.
+     * Binds a DataSource into JNDI.
      *
      * @throws Exception if creation or binding fails.
      */
@@ -117,9 +117,9 @@ public class TestJndi {
     }
 
     /**
-     * Retrieves a DataSource from jndi.
+     * Retrieves a DataSource from JNDI.
      *
-     * @throws Exception if the jndi lookup fails or no DataSource is bound.
+     * @throws Exception if the JNDI lookup fails or no DataSource is bound.
      */
     protected DataSource retrieveDataSource() throws Exception {
         final Context ctx = getInitialContext();