db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1464835 - in /db/derby/code/trunk/java/client/org/apache/derby/client: am/Configuration.java am/Connection.java net/NetConnection.java
Date Fri, 05 Apr 2013 05:38:40 GMT
Author: dag
Date: Fri Apr  5 05:38:40 2013
New Revision: 1464835

URL: http://svn.apache.org/r1464835
Log:
DERBY-6125 Code clean up in client driver.

Patch derby-6125-03-04-followup. Incorporates Knut's further
simplification suggestions for patches 03 and 04:

After the 04-a patch, these three methods in NetConnection do nothing except calling the method
with the same name in the super class:

  - close()
  - closeX()
  - closeResources()

Removed, let NetConnection inherit them from its super class.

Make Connection.closeX() private and unsynchronized, as it will only
be called from Connection.close().

The patch also touches NetConnection's closeForReuse() method, which
doesn't have any callers. Removed.

Replaces System.arraycopy with Object.clone for byte array copies as
suggested.

NetConnection.completeConnect(): remove the override and make the
super method final instead.


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java?rev=1464835&r1=1464834&r2=1464835&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Configuration.java Fri Apr
 5 05:38:40 2013
@@ -59,9 +59,7 @@ public class Configuration {
             {0x53, 0x59, 0x53, 0x4c, 0x56, 0x4c, 0x30, 0x31};
 
     public static byte[] getDncPackageConsistencyToken() {
-        byte [] cpy = new byte[dncPackageConsistencyToken.length];
-        System.arraycopy(dncPackageConsistencyToken, 0, cpy, 0, cpy.length);
-        return cpy;
+        return dncPackageConsistencyToken.clone();
     }
 
     // We will not set package VERSION in the initial release.
@@ -75,9 +73,7 @@ public class Configuration {
             {"1.5", "1.6", "1.7", "1.8"};
 
     public static String[] getDncCompatibleJREVersions() {
-        String[] cpy = new String[dncCompatibleJREVersions.length];
-        System.arraycopy(dncCompatibleJREVersions, 0, cpy, 0, cpy.length);
-        return cpy;
+        return dncCompatibleJREVersions.clone();
     }
 
     //---------------------- database URL protocols ------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=1464835&r1=1464834&r2=1464835&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Fri Apr  5
05:38:40 2013
@@ -764,7 +764,7 @@ public abstract class Connection
     }
 
     // This is a no-op if the connection is already closed.
-    synchronized public void closeX() throws SQLException {
+    private void closeX() throws SQLException {
         if (!open_ && !isAborting()) {
             return;
         }
@@ -2048,7 +2048,7 @@ public abstract class Connection
     // All callbacks must be client-side only operations.
 
 
-    public void completeConnect() throws SqlException {
+    public final void completeConnect() throws SqlException {
         open_ = true;
         databaseMetaData_ = newDatabaseMetaData_();
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=1464835&r1=1464834&r2=1464835&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Fri Apr
 5 05:38:40 2013
@@ -374,10 +374,6 @@ public class NetConnection extends org.a
         }
     }
 
-    public final void completeConnect() throws SqlException {
-        super.completeConnect();
-    }
-
     protected void completeReset(boolean isDeferredReset)
             throws SqlException {
         super.completeReset(isDeferredReset, closeStatementsOnClose, xares_);
@@ -1649,9 +1645,7 @@ public class NetConnection extends org.a
     }
 
     public byte[] getTargetPublicKey() {
-        byte[] cpy = new byte[targetPublicKey_.length];
-        System.arraycopy(targetPublicKey_, 0, cpy, 0, cpy.length);
-        return cpy;
+        return targetPublicKey_.clone();
     }
 
     public String getProductID() {
@@ -1783,40 +1777,6 @@ public class NetConnection extends org.a
     }
     
     /**
-     * closes underlying connection and associated resource.
-     */
-    synchronized public void close() throws SQLException {
-        // call super.close*() to do the close*
-        super.close();
-    }
-    
-    /**
-     * closes underlying connection and associated resource.
-     */
-    synchronized public void closeX() throws SQLException {
-        // call super.close*() to do the close*
-        super.closeX();
-    }
-    
-    /**
-     * Invalidates connection but keeps socket open.
-     */
-    synchronized public void closeForReuse() throws SqlException {
-        // call super.close*() to do the close*
-        super.closeForReuse(closeStatementsOnClose);
-    }
-    
-    /**
-     * closes resources connection will be not available 
-     * for reuse.
-     */
-    synchronized public void closeResources() throws SQLException {
-        // call super.close*() to do the close*
-        super.closeResources();
-    }
-    
-    
-    /**
      * Invokes write commit on NetXAConnection
      */
     protected void writeXACommit_() throws SqlException {



Mime
View raw message