Program: 112232
Project: 112232
Buggy source:
@Override @Transactional(value=TxType.NOT_SUPPORTED) public List<Long> getResources(final String theUuid,int theFrom,int theTo){
  if (myNeverUseLocalSearchForUnitTests == false) {
    SearchTask task=myIdToSearchTask.get(theUuid);
    if (task != null) {
      return task.getResourcePids(theFrom,theTo);
    }
  }
  Search search;
  StopWatch sw=new StopWatch();
  while (true) {
    TransactionTemplate txTemplate=new TransactionTemplate(myTxManager);
    txTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
    search=txTemplate.execute(new TransactionCallback<Search>(){
      @Override public Search doInTransaction(      TransactionStatus theStatus){
        return mySearchDao.findByUuid(theUuid);
      }
    }
);
    if (search == null) {
      ourLog.info("String_Node_Str",theUuid);
      String msg=myContext.getLocalizer().getMessage(PageMethodBinding.class,"String_Node_Str",theUuid);
      throw new ResourceGoneException(msg);
    }
    verifySearchHasntFailedOrThrowInternalErrorException(search);
    if (search.getStatus() == SearchStatusEnum.FINISHED) {
      ourLog.info("String_Node_Str");
      break;
    }
    if (search.getNumFound() >= theTo) {
      ourLog.info("String_Node_Str",search.getNumFound());
      break;
    }
    if (sw.getMillis() > myMaxMillisToWaitForRemoteResults) {
      throw new InternalErrorException("String_Node_Str" + sw.getMillis() + "String_Node_Str");
    }
    try {
      Thread.sleep(500);
    }
 catch (    InterruptedException e) {
    }
  }
  Pageable page=toPage(theFrom,theTo);
  if (page == null) {
    return Collections.emptyList();
  }
  Page<SearchResult> searchResults=mySearchResultDao.findWithSearchUuid(search,page);
  List<Long> retVal=new ArrayList<Long>();
  for (  SearchResult next : searchResults) {
    retVal.add(next.getResourcePid());
  }
  return retVal;
}

Fixed version (ground truth):
@Override @Transactional(value=TxType.NOT_SUPPORTED) public List<Long> getResources(final String theUuid,int theFrom,int theTo){
  if (myNeverUseLocalSearchForUnitTests == false) {
    SearchTask task=myIdToSearchTask.get(theUuid);
    if (task != null) {
      return task.getResourcePids(theFrom,theTo);
    }
  }
  TransactionTemplate txTemplate=new TransactionTemplate(myTxManager);
  txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
  Search search;
  StopWatch sw=new StopWatch();
  while (true) {
    search=txTemplate.execute(new TransactionCallback<Search>(){
      @Override public Search doInTransaction(      TransactionStatus theStatus){
        return mySearchDao.findByUuid(theUuid);
      }
    }
);
    if (search == null) {
      ourLog.info("String_Node_Str",theUuid);
      String msg=myContext.getLocalizer().getMessage(PageMethodBinding.class,"String_Node_Str",theUuid);
      throw new ResourceGoneException(msg);
    }
    verifySearchHasntFailedOrThrowInternalErrorException(search);
    if (search.getStatus() == SearchStatusEnum.FINISHED) {
      ourLog.info("String_Node_Str");
      break;
    }
    if (search.getNumFound() >= theTo) {
      ourLog.info("String_Node_Str",search.getNumFound());
      break;
    }
    if (sw.getMillis() > myMaxMillisToWaitForRemoteResults) {
      throw new InternalErrorException("String_Node_Str" + sw.getMillis() + "String_Node_Str");
    }
    try {
      Thread.sleep(500);
    }
 catch (    InterruptedException e) {
    }
  }
  final Pageable page=toPage(theFrom,theTo);
  if (page == null) {
    return Collections.emptyList();
  }
  final Search foundSearch=search;
  List<Long> retVal=txTemplate.execute(new TransactionCallback<List<Long>>(){
    @Override public List<Long> doInTransaction(    TransactionStatus theStatus){
      final List<Long> resultPids=new ArrayList<Long>();
      Page<SearchResult> searchResults=mySearchResultDao.findWithSearchUuid(foundSearch,page);
      for (      SearchResult next : searchResults) {
        resultPids.add(next.getResourcePid());
      }
      return resultPids;
    }
  }
);
  return retVal;
}