Program: 13192
Project: 13192
Buggy source:
/** 
 * TEMPORARY. Future version will have this break-down into discrete units of work.
 * @param reconContext
 * @throws SynchronizationException
 */
private void doRecon(ReconciliationContext reconContext) throws SynchronizationException {
  reconContext.getStatistics().reconStart();
  String reconId=reconContext.getReconId();
  EventEntry measureIdQueries=Publisher.start(EVENT_RECON_ID_QUERIES,reconId,null);
  reconContext.setStage(ReconStage.ACTIVE_QUERY_ENTRIES);
  ServerContext context=ObjectSetContext.get();
  try {
    context=new TriggerContext(context,"String_Node_Str");
    ObjectSetContext.push(context);
    logReconStart(reconContext,context);
    reconContext.getStatistics().sourceQueryStart();
    ReconQueryResult sourceQueryResult=reconContext.querySourceIter(reconSourceQueryPageSize,null);
    Iterator<ResultEntry> sourceIter=sourceQueryResult.getIterator();
    reconContext.getStatistics().sourceQueryEnd();
    if (!sourceIter.hasNext()) {
      if (!reconContext.getReconHandler().allowEmptySourceSet()) {
        LOGGER.warn("String_Node_Str");
        reconContext.setStage(ReconStage.COMPLETED_FAILED);
        reconContext.getStatistics().reconEnd();
        logReconEndFailure(reconContext,context);
        return;
      }
    }
    Collection<String> remainingTargetIds=null;
    ResultIterable targetIterable=null;
    if (reconContext.getReconHandler().isRunTargetPhase()) {
      reconContext.getStatistics().targetQueryStart();
      targetIterable=reconContext.queryTarget();
      remainingTargetIds=targetIterable.getAllIds();
      reconContext.getStatistics().targetQueryEnd();
    }
 else {
      remainingTargetIds=new ArrayList<String>();
    }
    Map<String,Map<String,Link>> allLinks=null;
    if (prefetchLinks) {
      allLinks=new HashMap<String,Map<String,Link>>();
      Integer totalLinkEntries=new Integer(0);
      reconContext.getStatistics().linkQueryStart();
      for (      String linkQualifier : getAllLinkQualifiers()) {
        Map<String,Link> linksByQualifier=Link.getLinksForMapping(ObjectMapping.this,linkQualifier);
        allLinks.put(linkQualifier,linksByQualifier);
        totalLinkEntries+=linksByQualifier.size();
      }
      reconContext.setTotalLinkEntries(totalLinkEntries);
      reconContext.getStatistics().linkQueryEnd();
    }
    measureIdQueries.end();
    EventEntry measureSource=Publisher.start(EVENT_RECON_SOURCE,reconId,null);
    reconContext.setStage(ReconStage.ACTIVE_RECONCILING_SOURCE);
    reconContext.getStatistics().sourcePhaseStart();
    boolean queryNextPage=false;
    LOGGER.info("String_Node_Str",new Object[]{reconId,name});
    do {
      if (queryNextPage) {
        LOGGER.debug("String_Node_Str");
        sourceQueryResult=reconContext.querySourceIter(reconSourceQueryPageSize,sourceQueryResult.getPagingCookie());
        sourceIter=sourceQueryResult.getIterator();
      }
      ReconPhase sourcePhase=new ReconPhase(sourceIter,reconContext,context,allLinks,remainingTargetIds,sourceRecon);
      sourcePhase.execute();
      queryNextPage=true;
    }
 while (reconSourceQueryPaging && sourceQueryResult.getPagingCookie() != null);
    reconContext.getStatistics().sourcePhaseEnd();
    measureSource.end();
    LOGGER.debug("String_Node_Str",remainingTargetIds);
    if (reconContext.getReconHandler().isRunTargetPhase()) {
      EventEntry measureTarget=Publisher.start(EVENT_RECON_TARGET,reconId,null);
      reconContext.setStage(ReconStage.ACTIVE_RECONCILING_TARGET);
      targetIterable.removeNotMatchingEntries(remainingTargetIds);
      reconContext.getStatistics().targetPhaseStart();
      ReconPhase targetPhase=new ReconPhase(targetIterable.iterator(),reconContext,context,allLinks,null,targetRecon);
      targetPhase.execute();
      reconContext.getStatistics().targetPhaseEnd();
      measureTarget.end();
    }
    reconContext.getStatistics().reconEnd();
    reconContext.setStage(ReconStage.ACTIVE_PROCESSING_RESULTS);
    doResults(reconContext);
    reconContext.setStage(ReconStage.COMPLETED_SUCCESS);
    logReconEndSuccess(reconContext,context);
  }
 catch (  InterruptedException ex) {
    reconContext.checkCanceled();
    throw new SynchronizationException("String_Node_Str",ex);
  }
catch (  Exception e) {
    reconContext.setStage(ReconStage.COMPLETED_FAILED);
    reconContext.getStatistics().reconEnd();
    logReconEndFailure(reconContext,context);
    throw new SynchronizationException("String_Node_Str",e);
  }
 finally {
    ObjectSetContext.pop();
    if (!reconContext.getStatistics().hasEnded()) {
      reconContext.getStatistics().reconEnd();
    }
  }
}

Fixed version (ground truth):
/** 
 * TEMPORARY. Future version will have this break-down into discrete units of work.
 * @param reconContext
 * @throws SynchronizationException
 */
private void doRecon(ReconciliationContext reconContext) throws SynchronizationException {
  reconContext.getStatistics().reconStart();
  String reconId=reconContext.getReconId();
  EventEntry measureIdQueries=Publisher.start(EVENT_RECON_ID_QUERIES,reconId,null);
  reconContext.setStage(ReconStage.ACTIVE_QUERY_ENTRIES);
  ServerContext context=ObjectSetContext.get();
  try {
    context=new TriggerContext(context,"String_Node_Str");
    ObjectSetContext.push(context);
    logReconStart(reconContext,context);
    reconContext.getStatistics().sourceQueryStart();
    ReconQueryResult sourceQueryResult=reconContext.querySourceIter(reconSourceQueryPageSize,null);
    Iterator<ResultEntry> sourceIter=sourceQueryResult.getIterator();
    reconContext.getStatistics().sourceQueryEnd();
    if (!sourceIter.hasNext()) {
      if (!reconContext.getReconHandler().allowEmptySourceSet()) {
        LOGGER.warn("String_Node_Str");
        reconContext.setStage(ReconStage.COMPLETED_FAILED);
        reconContext.getStatistics().reconEnd();
        logReconEndFailure(reconContext,context);
        return;
      }
    }
    Collection<String> remainingTargetIds=null;
    ResultIterable targetIterable=null;
    if (reconContext.getReconHandler().isRunTargetPhase()) {
      reconContext.getStatistics().targetQueryStart();
      targetIterable=reconContext.queryTarget();
      remainingTargetIds=targetIterable.getAllIds();
      reconContext.getStatistics().targetQueryEnd();
    }
 else {
      remainingTargetIds=new ArrayList<String>();
    }
    Map<String,Map<String,Link>> allLinks=null;
    if (prefetchLinks) {
      allLinks=new HashMap<String,Map<String,Link>>();
      Integer totalLinkEntries=new Integer(0);
      reconContext.getStatistics().linkQueryStart();
      for (      String linkQualifier : getAllLinkQualifiers()) {
        Map<String,Link> linksByQualifier=Link.getLinksForMapping(ObjectMapping.this,linkQualifier);
        allLinks.put(linkQualifier,linksByQualifier);
        totalLinkEntries+=linksByQualifier.size();
      }
      reconContext.setTotalLinkEntries(totalLinkEntries);
      reconContext.getStatistics().linkQueryEnd();
    }
    measureIdQueries.end();
    EventEntry measureSource=Publisher.start(EVENT_RECON_SOURCE,reconId,null);
    reconContext.setStage(ReconStage.ACTIVE_RECONCILING_SOURCE);
    reconContext.getStatistics().sourcePhaseStart();
    boolean queryNextPage=false;
    LOGGER.info("String_Node_Str",new Object[]{reconId,name});
    do {
      if (queryNextPage) {
        LOGGER.debug("String_Node_Str");
        sourceQueryResult=reconContext.querySourceIter(reconSourceQueryPageSize,sourceQueryResult.getPagingCookie());
        sourceIter=sourceQueryResult.getIterator();
      }
      ReconPhase sourcePhase=new ReconPhase(sourceIter,reconContext,context,allLinks,remainingTargetIds,sourceRecon);
      sourcePhase.setFeedSize(feedSize);
      sourcePhase.execute();
      queryNextPage=true;
    }
 while (reconSourceQueryPaging && sourceQueryResult.getPagingCookie() != null);
    reconContext.getStatistics().sourcePhaseEnd();
    measureSource.end();
    LOGGER.debug("String_Node_Str",remainingTargetIds);
    if (reconContext.getReconHandler().isRunTargetPhase()) {
      EventEntry measureTarget=Publisher.start(EVENT_RECON_TARGET,reconId,null);
      reconContext.setStage(ReconStage.ACTIVE_RECONCILING_TARGET);
      targetIterable.removeNotMatchingEntries(remainingTargetIds);
      reconContext.getStatistics().targetPhaseStart();
      ReconPhase targetPhase=new ReconPhase(targetIterable.iterator(),reconContext,context,allLinks,null,targetRecon);
      targetPhase.setFeedSize(feedSize);
      targetPhase.execute();
      reconContext.getStatistics().targetPhaseEnd();
      measureTarget.end();
    }
    reconContext.getStatistics().reconEnd();
    reconContext.setStage(ReconStage.ACTIVE_PROCESSING_RESULTS);
    doResults(reconContext);
    reconContext.setStage(ReconStage.COMPLETED_SUCCESS);
    logReconEndSuccess(reconContext,context);
  }
 catch (  InterruptedException ex) {
    reconContext.checkCanceled();
    throw new SynchronizationException("String_Node_Str",ex);
  }
catch (  Exception e) {
    reconContext.setStage(ReconStage.COMPLETED_FAILED);
    reconContext.getStatistics().reconEnd();
    logReconEndFailure(reconContext,context);
    throw new SynchronizationException("String_Node_Str",e);
  }
 finally {
    ObjectSetContext.pop();
    if (!reconContext.getStatistics().hasEnded()) {
      reconContext.getStatistics().reconEnd();
    }
  }
}