db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1469243 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/access/xa/ iapi/store/raw/ iapi/store/raw/xact/ impl/store/raw/xact/
Date Thu, 18 Apr 2013 09:29:00 GMT
Author: kahatlen
Date: Thu Apr 18 09:29:00 2013
New Revision: 1469243

URL: http://svn.apache.org/r1469243
Log:
DERBY-6184: Clean up warnings in XA transaction id classes

- simplify existing cloning of arrays by using clone() instead of
  calling new and arraycopy

- reduce visibility of array-returning methods in GlobalXactId to make
  it clearer for code analysis tools that they are not called from
  outside of the package in which the class lives

- remove said methods from the GlobalTransactionId to allow them to be
  non-public

- make the public, array-returning methods in XAXactId return copies
  of the internal arrays to protect the internal state, as instances
  of this class may be returned all the way out to the user

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/xa/XAXactId.java Thu
Apr 18 09:29:00 2013
@@ -64,10 +64,8 @@ public class XAXactId extends GlobalXact
 							   byte[]  branch_id)
     {
 		this.format_id = format_id;
-		this.global_id = new byte[global_id.length];
-		System.arraycopy(global_id, 0, this.global_id, 0, global_id.length);
-		this.branch_id = new byte[branch_id.length];
-		System.arraycopy(branch_id, 0, this.branch_id, 0, branch_id.length);
+        this.global_id = (byte[]) global_id.clone();
+        this.branch_id = (byte[]) branch_id.clone();
     }
     
     /**
@@ -229,7 +227,7 @@ public class XAXactId extends GlobalXact
      **/
     public byte[] getGlobalTransactionId()
     {
-        return(global_id);
+        return (byte[]) global_id.clone();
     }
 
     /**
@@ -240,7 +238,7 @@ public class XAXactId extends GlobalXact
      **/
     public byte[] getBranchQualifier()
     {
-        return(branch_id);
+        return (byte[]) branch_id.clone();
     }
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/GlobalTransactionId.java
Thu Apr 18 09:29:00 2013
@@ -33,31 +33,5 @@ import org.apache.derby.iapi.services.io
 */
 public interface GlobalTransactionId extends Formatable 
 {
-    /**
-     * Obtain the format id part of the GlobalTransactionId.
-     * <p>
-     *
-	 * @return Format identifier. O means the OSI CCR format.
-     **/
-    public int getFormat_Id();
-
-    /**
-     * Obtain the global transaction identifier part of GlobalTransactionId 
-     * as an array of bytes.
-     * <p>
-     *
-	 * @return A byte array containing the global transaction identifier.
-     **/
-    public byte[] getGlobalTransactionId();
-
-    /**
-     * Obtain the transaction branch qualifier part of the GlobalTransactionId
-     * in a byte array.
-     * <p>
-     *
-	 * @return A byte array containing the branch qualifier of the transaction.
-     **/
-    public byte[] getBranchQualifier();
-
 	/* need to write a value based HashCode() method. */
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/xact/RawTransaction.java
Thu Apr 18 09:29:00 2013
@@ -38,8 +38,6 @@ import org.apache.derby.iapi.error.Stand
 
 import org.apache.derby.iapi.util.ByteArray;
 import org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream;
-import org.apache.derby.catalog.UUID;
-
 
 import java.util.Observable;
 
@@ -118,11 +116,6 @@ public abstract class RawTransaction ext
 
 	/** Methods to help logging and recovery */
 
-	/** 
-		Set the transaction Ids (Global and internal) of this transaction
-	*/
-	public abstract void setTransactionId(GlobalTransactionId id, TransactionId shortId);
-
 	/**
 		Set the transactionId (Global and internal) of this transaction using a
 		log record that contains the Global id

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/GlobalXactId.java
Thu Apr 18 09:29:00 2013
@@ -23,15 +23,11 @@ package org.apache.derby.impl.store.raw.
 
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
-import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
-import org.apache.derby.catalog.UUID;
 
 import org.apache.derby.iapi.store.raw.GlobalTransactionId;
 import org.apache.derby.iapi.store.access.GlobalXact;
 
-import org.apache.derby.iapi.util.ByteArray;
-
 import java.io.ObjectOutput;
 import java.io.ObjectInput;
 import java.io.IOException;
@@ -47,16 +43,14 @@ public class GlobalXactId extends Global
      * Constructors for This class:
      **************************************************************************
      */
-	public GlobalXactId(
+    GlobalXactId(
 						int     format_id,
 						byte[]  global_id,
 						byte[]  branch_id)
     {
 		this.format_id = format_id;
-		this.global_id = new byte[global_id.length];
-		System.arraycopy(global_id, 0, this.global_id, 0, global_id.length);
-		this.branch_id = new byte[branch_id.length];
-		System.arraycopy(branch_id, 0, this.branch_id, 0, branch_id.length);
+        this.global_id = (byte[]) global_id.clone();
+        this.branch_id = (byte[]) branch_id.clone();
 	}
 
     /**************************************************************************
@@ -142,21 +136,29 @@ public class GlobalXactId extends Global
      **************************************************************************
      */
 
-    /**************************************************************************
-     * Public Methods of This class:
-     **************************************************************************
+    /**
+     * Obtain the format id part of the GlobalTransactionId.
+     * @return format identifier, 0 means the OSI CCR format
      */
-    public int getFormat_Id()
+    int getFormat_Id()
     {
         return(format_id);
     }
 
-    public byte[] getGlobalTransactionId()
+    /**
+     * Obtain the global transaction identifier as an array of bytes.
+     * @return a byte array containing the global transaction identifier
+     */
+    byte[] getGlobalTransactionId()
     {
         return(global_id);
     }
 
-    public byte[] getBranchQualifier()
+    /**
+     * Obtain the transaction branch qualifier as an array of bytes.
+     * @return a byte array containing the branch qualifier of the transaction
+     */
+    byte[] getBranchQualifier()
     {
         return(branch_id);
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/Xact.java Thu Apr
18 09:29:00 2013
@@ -479,7 +479,7 @@ public class Xact extends RawTransaction
 	/**
 		Set my transaction identifier.
 	*/
-	public void setTransactionId(GlobalTransactionId extid, TransactionId localid) {
+    void setTransactionId(GlobalTransactionId extid, TransactionId localid) {
 
 		if (SanityManager.DEBUG) {
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactFactory.java
Thu Apr 18 09:29:00 2013
@@ -35,7 +35,6 @@ import org.apache.derby.iapi.services.mo
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.io.Formatable;
-import org.apache.derby.iapi.services.io.FormatIdUtil;
 import org.apache.derby.iapi.services.uuid.UUIDFactory;
 import org.apache.derby.catalog.UUID;
 
@@ -43,14 +42,8 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.store.access.TransactionController;
 import org.apache.derby.iapi.store.access.TransactionInfo;
 
-import org.apache.derby.iapi.store.access.AccessFactory;
-
-import org.apache.derby.iapi.store.access.xa.XAResourceManager;
-
 import org.apache.derby.iapi.store.raw.LockingPolicy;
-import org.apache.derby.iapi.store.raw.GlobalTransactionId;
 import org.apache.derby.iapi.store.raw.RawStoreFactory;
-import org.apache.derby.iapi.store.raw.Transaction;
 
 import org.apache.derby.iapi.store.raw.data.DataFactory;
 
@@ -60,7 +53,6 @@ import org.apache.derby.iapi.store.raw.l
 import org.apache.derby.iapi.store.raw.xact.RawTransaction;
 import org.apache.derby.iapi.store.raw.xact.TransactionFactory;
 import org.apache.derby.iapi.store.raw.xact.TransactionId;
-import org.apache.derby.impl.store.raw.xact.XactXAResourceManager;
 
 import org.apache.derby.iapi.types.DataValueFactory;
 
@@ -68,9 +60,7 @@ import org.apache.derby.iapi.error.Stand
 
 import org.apache.derby.iapi.util.InterruptStatus;
 
-import java.util.Enumeration;
 import java.util.Properties;
-import java.util.Hashtable;
 
 public class XactFactory implements TransactionFactory, ModuleControl, ModuleSupportable
 {
@@ -311,7 +301,7 @@ public class XactFactory implements Tran
      *
 	 * @exception  StandardException  Standard exception policy.
      **/
-	private RawTransaction startCommonTransaction(
+    private Xact startCommonTransaction(
     RawStoreFactory     rsf, 
     ContextManager      cm,
     boolean             readOnly,
@@ -421,7 +411,7 @@ public class XactFactory implements Tran
             throw StandardException.newException(SQLState.STORE_XA_XAER_DUPID);
         }
 
-        RawTransaction xact = 
+        Xact xact =
             startCommonTransaction(
                 rsf, 
                 cm, 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java?rev=1469243&r1=1469242&r2=1469243&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/xact/XactXAResourceManager.java
Thu Apr 18 09:29:00 2013
@@ -33,7 +33,6 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.store.access.xa.XAXactId;
 import org.apache.derby.iapi.store.access.AccessFactoryGlobals;
 
-import org.apache.derby.iapi.store.raw.GlobalTransactionId;
 import org.apache.derby.iapi.store.raw.RawStoreFactory;
 import org.apache.derby.iapi.store.raw.Transaction;
 
@@ -253,7 +252,7 @@ public class XactXAResourceManager imple
                     Xact xact = entry.getXact();
                     if (xact.isPrepared())
                     {
-                        GlobalTransactionId xa_id = xact.getGlobalId();
+                        GlobalXactId xa_id = (GlobalXactId) xact.getGlobalId();
 
                         xid_list.add(
                             new XAXactId(



Mime
View raw message