geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager Recovery.java
Date Tue, 08 Jun 2004 20:12:35 GMT
djencks     2004/06/08 13:12:35

  Modified:    modules/transaction/src/java/org/apache/geronimo/transaction/manager
                        Recovery.java
  Log:
  Fix some embarassing mistakes
  
  Revision  Changes    Path
  1.3       +33 -3     incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java
  
  Index: Recovery.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/manager/Recovery.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Recovery.java	8 Jun 2004 17:33:42 -0000	1.2
  +++ Recovery.java	8 Jun 2004 20:12:34 -0000	1.3
  @@ -24,6 +24,7 @@
   import java.util.Set;
   import java.util.ArrayList;
   import java.util.Collections;
  +import java.util.Arrays;
   
   import javax.transaction.SystemException;
   import javax.transaction.xa.XAException;
  @@ -51,6 +52,7 @@
       private final Map externalGlobalIdMap = new HashMap();
   
       private final List recoveryErrors = new ArrayList();
  +    private ByteArrayWrapper globalIdWrapper;
   
       public Recovery(final List xaResources, final TransactionLog txLog, final XidFactory
xidFactory) {
           this.xaResources = xaResources;
  @@ -79,7 +81,7 @@
               Xid xid = (Xid) entry.getKey();
               if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
                   XidNamesPair xidNamesPair = new XidNamesPair(xid, (Set) entry.getValue());
  -                ourXids.put(xid.getGlobalTransactionId(), xidNamesPair);
  +                ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidNamesPair);
               } else {
                   TransactionImpl externalTx = new ExternalTransaction(xid, txLog, (Set)
entry.getValue());
                   externalXids.put(xid, externalTx);
  @@ -93,7 +95,8 @@
           Xid[] prepared = xaResource.recover(XAResource.TMSTARTRSCAN + XAResource.TMENDRSCAN);
           for (int i = 0; i < prepared.length; i++) {
               Xid xid = prepared[i];
  -            XidNamesPair xidNamesPair = (XidNamesPair) ourXids.get(xid.getGlobalTransactionId());
  +            globalIdWrapper = new ByteArrayWrapper(xid.getGlobalTransactionId());
  +            XidNamesPair xidNamesPair = (XidNamesPair) ourXids.get(globalIdWrapper);
               if (xidNamesPair != null) {
                   try {
                       xaResource.commit(xid, false);
  @@ -106,6 +109,7 @@
                   }
                   if (xidNamesPair.resourceNames.isEmpty()) {
                       try {
  +                        ourXids.remove(globalIdWrapper);
                           txLog.commit(xidNamesPair.xid);
                       } catch (LogException e) {
                           recoveryErrors.add(e);
  @@ -167,6 +171,32 @@
           public XidNamesPair(Xid xid, Set resourceNames) {
               this.xid = xid;
               this.resourceNames = resourceNames;
  +        }
  +    }
  +
  +    private static class ByteArrayWrapper {
  +        private final byte[] bytes;
  +        private final int hashCode;
  +
  +        public ByteArrayWrapper(final byte[] bytes) {
  +            assert bytes != null;
  +            this.bytes = bytes;
  +            int hash = 0;
  +            for (int i = 0; i < bytes.length; i++) {
  +                hash += 37 * bytes[i];
  +            }
  +            hashCode = hash;
  +        }
  +
  +        public boolean equals(Object other) {
  +            if (other instanceof ByteArrayWrapper) {
  +                return Arrays.equals(bytes, ((ByteArrayWrapper)other).bytes);
  +            }
  +            return false;
  +        }
  +
  +        public int hashCode() {
  +            return hashCode;
           }
       }
   
  
  
  

Mime
View raw message