Program: 155498
Project: 155498
Buggy source:
/** 
 * Call   {@link XAResource#recover(int)} on the resource and fill the <code>alreadyRecoveredXids</code> Setwith recovered  {@link BitronixXid}s. Step 1.
 * @return the amount of recovered {@link Xid}.
 * @param resourceHolderState the {@link XAResourceHolderState} to recover.
 * @param alreadyRecoveredXids a set of {@link Xid}s already recovered from this resource in this recovery session.
 * @param flags any combination of {@link XAResource#TMSTARTRSCAN},   {@link XAResource#TMNOFLAGS} or {@link XAResource#TMENDRSCAN}.
 * @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails.
 */
private static int recover(XAResourceHolderState resourceHolderState,Set alreadyRecoveredXids,int flags) throws XAException {
  Xid[] xids=resourceHolderState.getXAResource().recover(flags);
  if (xids == null)   return 0;
  Set freshlyRecoveredXids=new HashSet();
  for (int i=0; i < xids.length; i++) {
    Xid xid=xids[i];
    if (xid.getFormatId() != BitronixXid.FORMAT_ID) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xid + "String_Node_Str"+ xid.getFormatId()+ "String_Node_Str"+ new Uid(xid.getGlobalTransactionId())+ "String_Node_Str"+ new Uid(xid.getBranchQualifier())+ "String_Node_Str");
      continue;
    }
    BitronixXid bitronixXid=new BitronixXid(xid);
    String extractedServerId=bitronixXid.getGlobalTransactionIdUid().extractServerId();
    String jvmUniqueId=TransactionManagerServices.getConfiguration().getServerId();
    if (!extractedServerId.equals(jvmUniqueId)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + bitronixXid + "String_Node_Str"+ extractedServerId+ "String_Node_Str"+ jvmUniqueId+ "String_Node_Str");
      continue;
    }
    if (alreadyRecoveredXids.contains(bitronixXid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + bitronixXid + "String_Node_Str");
      continue;
    }
    if (freshlyRecoveredXids.contains(bitronixXid)) {
      log.warn("String_Node_Str" + resourceHolderState.getUniqueName() + "String_Node_Str"+ bitronixXid);
      continue;
    }
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + bitronixXid);
    freshlyRecoveredXids.add(bitronixXid);
  }
  alreadyRecoveredXids.addAll(freshlyRecoveredXids);
  return freshlyRecoveredXids.size();
}

Fixed version (ground truth):
/** 
 * Call   {@link XAResource#recover(int)} on the resource and fill the <code>alreadyRecoveredXids</code> Setwith recovered  {@link BitronixXid}s. Step 1.
 * @return the amount of recovered {@link Xid}.
 * @param resourceHolderState the {@link XAResourceHolderState} to recover.
 * @param alreadyRecoveredXids a set of {@link Xid}s already recovered from this resource in this recovery session.
 * @param flags any combination of {@link XAResource#TMSTARTRSCAN},   {@link XAResource#TMNOFLAGS} or {@link XAResource#TMENDRSCAN}.
 * @throws javax.transaction.xa.XAException if {@link XAResource#recover(int)} call fails.
 */
private static int recover(XAResourceHolderState resourceHolderState,Set alreadyRecoveredXids,int flags) throws XAException {
  Xid[] xids=resourceHolderState.getXAResource().recover(flags);
  if (xids == null)   return 0;
  Set freshlyRecoveredXids=new HashSet();
  for (int i=0; i < xids.length; i++) {
    Xid xid=xids[i];
    if (xid.getFormatId() != BitronixXid.FORMAT_ID) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + xid + "String_Node_Str"+ xid.getFormatId()+ "String_Node_Str"+ new Uid(xid.getGlobalTransactionId())+ "String_Node_Str"+ new Uid(xid.getBranchQualifier())+ "String_Node_Str");
      continue;
    }
    BitronixXid bitronixXid=new BitronixXid(xid);
    byte[] extractedServerId=bitronixXid.getGlobalTransactionIdUid().extractServerId();
    byte[] jvmUniqueId=TransactionManagerServices.getConfiguration().buildServerIdArray();
    if (extractedServerId == null) {
      log.warn("String_Node_Str" + bitronixXid + "String_Node_Str");
      continue;
    }
    if (!Arrays.equals(jvmUniqueId,extractedServerId)) {
      String extractedServerIdString=new String(extractedServerId);
      String jvmUniqueIdString=new String(jvmUniqueId);
      log.info("String_Node_Str" + bitronixXid + "String_Node_Str"+ extractedServerIdString+ "String_Node_Str"+ jvmUniqueIdString+ "String_Node_Str"+ "String_Node_Str"+ extractedServerIdString+ "String_Node_Str");
      continue;
    }
    if (alreadyRecoveredXids.contains(bitronixXid)) {
      if (log.isDebugEnabled())       log.debug("String_Node_Str" + bitronixXid + "String_Node_Str");
      continue;
    }
    if (freshlyRecoveredXids.contains(bitronixXid)) {
      log.warn("String_Node_Str" + resourceHolderState.getUniqueName() + "String_Node_Str"+ bitronixXid);
      continue;
    }
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + bitronixXid);
    freshlyRecoveredXids.add(bitronixXid);
  }
  alreadyRecoveredXids.addAll(freshlyRecoveredXids);
  return freshlyRecoveredXids.size();
}