Program: 82694
Project: 82694
Buggy source:
public ResolvedModuleRevision getDependency(DependencyDescriptor dd,ResolveData data) throws ParseException {
  data=new ResolveData(data,doValidate(data));
  ResolvedModuleRevision ret=null;
  List errors=new ArrayList();
  ResolvedModuleRevision mr=null;
  ModuleRevisionId mrid=dd.getDependencyRevisionId();
  Message.verbose(getName() + "String_Node_Str" + dd);
  mr=findModuleInCache(dd,getCacheOptions(data),true);
  if (mr != null) {
    Message.verbose(getName() + "String_Node_Str" + mr.getId());
    return resolvedRevision(mr);
  }
  boolean isDynamic=getSettings().getVersionMatcher().isDynamic(mrid);
  for (Iterator iter=chain.iterator(); iter.hasNext(); ) {
    DependencyResolver resolver=(DependencyResolver)iter.next();
    LatestStrategy oldLatest=setLatestIfRequired(resolver,getLatestStrategy());
    try {
      mr=resolver.getDependency(dd,data);
    }
 catch (    Exception ex) {
      Message.verbose("String_Node_Str" + dd + "String_Node_Str"+ resolver+ "String_Node_Str"+ ex);
      errors.add(ex);
    }
 finally {
      if (oldLatest != null) {
        setLatest(resolver,oldLatest);
      }
    }
    checkInterrupted();
    if (mr != null) {
      boolean shouldReturn=returnFirst;
      shouldReturn|=!isDynamic && ret != null && !ret.getDescriptor().isDefault();
      if (!shouldReturn) {
        String mrDesc=mr.getId() + (mr.getDescriptor().isDefault() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ mr.getResolver().getName();
        Message.debug("String_Node_Str" + mrDesc + "String_Node_Str"+ ret);
        if (ret == null) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else         if (isAfter(mr,ret,data.getDate())) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else         if (!mr.getDescriptor().isDefault() && ret.getDescriptor().isDefault()) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else {
          Message.debug("String_Node_Str" + mrDesc);
        }
        if (!isDynamic && !ret.getDescriptor().isDefault()) {
          Message.debug("String_Node_Str" + mrDesc);
          return resolvedRevision(mr);
        }
      }
 else {
        return resolvedRevision(mr);
      }
    }
  }
  if (ret == null && !errors.isEmpty()) {
    if (errors.size() == 1) {
      Exception ex=(Exception)errors.get(0);
      if (ex instanceof RuntimeException) {
        throw (RuntimeException)ex;
      }
 else       if (ex instanceof ParseException) {
        throw (ParseException)ex;
      }
 else {
        throw new RuntimeException(ex.toString(),ex);
      }
    }
 else {
      StringBuffer err=new StringBuffer();
      for (Iterator iter=errors.iterator(); iter.hasNext(); ) {
        Exception ex=(Exception)iter.next();
        err.append(ex).append("String_Node_Str");
      }
      err.setLength(err.length() - 1);
      throw new RuntimeException("String_Node_Str" + dd + "String_Node_Str"+ err);
    }
  }
  return resolvedRevision(ret);
}

Fixed version (ground truth):
public ResolvedModuleRevision getDependency(DependencyDescriptor dd,ResolveData data) throws ParseException {
  data=new ResolveData(data,doValidate(data));
  ResolvedModuleRevision ret=null;
  List errors=new ArrayList();
  ResolvedModuleRevision mr=null;
  ModuleRevisionId mrid=dd.getDependencyRevisionId();
  Message.verbose(getName() + "String_Node_Str" + dd);
  mr=findModuleInCache(dd,getCacheOptions(data),true);
  if (mr != null) {
    Message.verbose(getName() + "String_Node_Str" + mr.getId());
    return resolvedRevision(mr);
  }
  boolean isDynamic=getSettings().getVersionMatcher().isDynamic(mrid);
  for (Iterator iter=chain.iterator(); iter.hasNext(); ) {
    DependencyResolver resolver=(DependencyResolver)iter.next();
    LatestStrategy oldLatest=setLatestIfRequired(resolver,getLatestStrategy());
    try {
      mr=resolver.getDependency(dd,data);
    }
 catch (    Exception ex) {
      Message.verbose("String_Node_Str" + dd + "String_Node_Str"+ resolver+ "String_Node_Str"+ StringUtils.getStackTrace(ex));
      errors.add(ex);
    }
 finally {
      if (oldLatest != null) {
        setLatest(resolver,oldLatest);
      }
    }
    checkInterrupted();
    if (mr != null) {
      boolean shouldReturn=returnFirst;
      shouldReturn|=!isDynamic && ret != null && !ret.getDescriptor().isDefault();
      if (!shouldReturn) {
        String mrDesc=mr.getId() + (mr.getDescriptor().isDefault() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ mr.getResolver().getName();
        Message.debug("String_Node_Str" + mrDesc + "String_Node_Str"+ ret);
        if (ret == null) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else         if (isAfter(mr,ret,data.getDate())) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else         if (!mr.getDescriptor().isDefault() && ret.getDescriptor().isDefault()) {
          Message.debug("String_Node_Str" + mrDesc);
          ret=mr;
        }
 else {
          Message.debug("String_Node_Str" + mrDesc);
        }
        if (!isDynamic && !ret.getDescriptor().isDefault()) {
          Message.debug("String_Node_Str" + mrDesc);
          return resolvedRevision(mr);
        }
      }
 else {
        return resolvedRevision(mr);
      }
    }
  }
  if (ret == null && !errors.isEmpty()) {
    if (errors.size() == 1) {
      Exception ex=(Exception)errors.get(0);
      if (ex instanceof RuntimeException) {
        throw (RuntimeException)ex;
      }
 else       if (ex instanceof ParseException) {
        throw (ParseException)ex;
      }
 else {
        throw new RuntimeException(ex.toString(),ex);
      }
    }
 else {
      StringBuffer err=new StringBuffer();
      for (Iterator iter=errors.iterator(); iter.hasNext(); ) {
        Exception ex=(Exception)iter.next();
        err.append("String_Node_Str").append(StringUtils.getErrorMessage(ex)).append("String_Node_Str");
      }
      err.setLength(err.length() - 1);
      throw new RuntimeException("String_Node_Str" + dd + "String_Node_Str"+ err);
    }
  }
  return resolvedRevision(ret);
}