Program: 17272
Project: 17272
Buggy source:
/** 
 * The crux of the matter...
 * @param host {@link MapHost} from which we need to  shuffle available map-outputs.
 */
@VisibleForTesting protected void copyFromHost(MapHost host) throws IOException {
  List<InputAttemptIdentifier> srcAttempts=scheduler.getMapsForHost(host);
  if (srcAttempts.size() == 0) {
    return;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + id + "String_Node_Str"+ host+ "String_Node_Str"+ srcAttempts);
  }
  remaining=new LinkedHashSet<InputAttemptIdentifier>(srcAttempts);
  DataInputStream input;
  boolean connectSucceeded=false;
  try {
    URL url=getMapOutputURL(host,srcAttempts);
    HttpURLConnection connection=openConnection(url);
    String msgToEncode=SecureShuffleUtils.buildMsgFrom(url);
    String encHash=SecureShuffleUtils.hashFromString(msgToEncode,jobTokenSecret);
    connection.addRequestProperty(SecureShuffleUtils.HTTP_HEADER_URL_HASH,encHash);
    connection.setReadTimeout(readTimeout);
    connection.addRequestProperty(ShuffleHeader.HTTP_HEADER_NAME,ShuffleHeader.DEFAULT_HTTP_HEADER_NAME);
    connection.addRequestProperty(ShuffleHeader.HTTP_HEADER_VERSION,ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION);
    connect(connection,connectionTimeout);
    connectSucceeded=true;
    input=new DataInputStream(new BufferedInputStream(connection.getInputStream(),bufferSize));
    int rc=connection.getResponseCode();
    if (rc != HttpURLConnection.HTTP_OK) {
      throw new IOException("String_Node_Str" + rc + "String_Node_Str"+ url+ "String_Node_Str"+ connection.getResponseMessage());
    }
    if (!ShuffleHeader.DEFAULT_HTTP_HEADER_NAME.equals(connection.getHeaderField(ShuffleHeader.HTTP_HEADER_NAME)) || !ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION.equals(connection.getHeaderField(ShuffleHeader.HTTP_HEADER_VERSION))) {
      throw new IOException("String_Node_Str");
    }
    String replyHash=connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
    if (replyHash == null) {
      throw new IOException("String_Node_Str");
    }
    LOG.debug("String_Node_Str" + msgToEncode + "String_Node_Str"+ encHash+ "String_Node_Str"+ replyHash);
    SecureShuffleUtils.verifyReply(replyHash,encHash,jobTokenSecret);
    LOG.info("String_Node_Str" + msgToEncode + "String_Node_Str");
  }
 catch (  IOException ie) {
    ioErrs.increment(1);
    LOG.warn("String_Node_Str" + host + "String_Node_Str"+ remaining.size()+ "String_Node_Str",ie);
    if (!connectSucceeded) {
      for (      InputAttemptIdentifier left : remaining) {
        scheduler.copyFailed(left,host,connectSucceeded);
      }
      remaining.clear();
    }
 else {
      InputAttemptIdentifier firstMap=srcAttempts.get(0);
      scheduler.copyFailed(firstMap,host,connectSucceeded);
      remaining.remove(firstMap);
    }
    for (    InputAttemptIdentifier left : remaining) {
      scheduler.putBackKnownMapOutput(host,left);
    }
    return;
  }
  try {
    InputAttemptIdentifier[] failedTasks=null;
    while (!remaining.isEmpty() && failedTasks == null) {
      failedTasks=copyMapOutput(host,input);
    }
    if (failedTasks != null && failedTasks.length > 0) {
      LOG.warn("String_Node_Str" + Arrays.toString(failedTasks));
      for (      InputAttemptIdentifier left : failedTasks) {
        scheduler.copyFailed(left,host,true);
        remaining.remove(left);
      }
    }
    IOUtils.cleanup(LOG,input);
    if (failedTasks == null && !remaining.isEmpty()) {
      throw new IOException("String_Node_Str" + remaining.size() + "String_Node_Str");
    }
  }
  finally {
    for (    InputAttemptIdentifier left : remaining) {
      scheduler.putBackKnownMapOutput(host,left);
    }
  }
}

Fixed version (ground truth):
/** 
 * The crux of the matter...
 * @param host {@link MapHost} from which we need to  shuffle available map-outputs.
 */
@VisibleForTesting protected void copyFromHost(MapHost host) throws IOException {
  List<InputAttemptIdentifier> srcAttempts=scheduler.getMapsForHost(host);
  currentPartition=host.getPartitionId();
  if (srcAttempts.size() == 0) {
    return;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str" + id + "String_Node_Str"+ host+ "String_Node_Str"+ srcAttempts+ "String_Node_Str"+ currentPartition);
  }
  remaining=new LinkedHashSet<InputAttemptIdentifier>(srcAttempts);
  DataInputStream input;
  boolean connectSucceeded=false;
  try {
    URL url=getMapOutputURL(host,srcAttempts);
    HttpURLConnection connection=openConnection(url);
    String msgToEncode=SecureShuffleUtils.buildMsgFrom(url);
    String encHash=SecureShuffleUtils.hashFromString(msgToEncode,jobTokenSecret);
    connection.addRequestProperty(SecureShuffleUtils.HTTP_HEADER_URL_HASH,encHash);
    connection.setReadTimeout(readTimeout);
    connection.addRequestProperty(ShuffleHeader.HTTP_HEADER_NAME,ShuffleHeader.DEFAULT_HTTP_HEADER_NAME);
    connection.addRequestProperty(ShuffleHeader.HTTP_HEADER_VERSION,ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION);
    connect(connection,connectionTimeout);
    connectSucceeded=true;
    input=new DataInputStream(new BufferedInputStream(connection.getInputStream(),bufferSize));
    int rc=connection.getResponseCode();
    if (rc != HttpURLConnection.HTTP_OK) {
      throw new IOException("String_Node_Str" + rc + "String_Node_Str"+ url+ "String_Node_Str"+ connection.getResponseMessage());
    }
    if (!ShuffleHeader.DEFAULT_HTTP_HEADER_NAME.equals(connection.getHeaderField(ShuffleHeader.HTTP_HEADER_NAME)) || !ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION.equals(connection.getHeaderField(ShuffleHeader.HTTP_HEADER_VERSION))) {
      throw new IOException("String_Node_Str");
    }
    String replyHash=connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
    if (replyHash == null) {
      throw new IOException("String_Node_Str");
    }
    LOG.debug("String_Node_Str" + msgToEncode + "String_Node_Str"+ encHash+ "String_Node_Str"+ replyHash);
    SecureShuffleUtils.verifyReply(replyHash,encHash,jobTokenSecret);
    LOG.info("String_Node_Str" + msgToEncode + "String_Node_Str");
  }
 catch (  IOException ie) {
    ioErrs.increment(1);
    if (!connectSucceeded) {
      LOG.warn("String_Node_Str" + host + "String_Node_Str"+ remaining.size()+ "String_Node_Str",ie);
      connectionErrs.increment(1);
    }
 else {
      LOG.warn("String_Node_Str" + host + "String_Node_Str"+ remaining.size()+ "String_Node_Str",ie);
    }
    for (    InputAttemptIdentifier left : remaining) {
      scheduler.copyFailed(left,host,!connectSucceeded);
    }
    putBackRemainingMapOutputs(host);
    return;
  }
  try {
    InputAttemptIdentifier[] failedTasks=null;
    while (!remaining.isEmpty() && failedTasks == null) {
      failedTasks=copyMapOutput(host,input);
    }
    if (failedTasks != null && failedTasks.length > 0) {
      LOG.warn("String_Node_Str" + Arrays.toString(failedTasks));
      for (      InputAttemptIdentifier left : failedTasks) {
        scheduler.copyFailed(left,host,true);
      }
    }
    IOUtils.cleanup(LOG,input);
    if (failedTasks == null && !remaining.isEmpty()) {
      throw new IOException("String_Node_Str" + remaining.size() + "String_Node_Str");
    }
  }
  finally {
    putBackRemainingMapOutputs(host);
  }
}