Sfoglia il codice sorgente

MAPREDUCE-3992. Reduce fetcher doesn't verify HTTP status code of response. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1304963 13f79535-47bb-0310-9956-ffa450edef68
Todd Lipcon 13 anni fa
parent
commit
d98b474ef0
2 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 3 0
      CHANGES.txt
  2. 10 1
      src/mapred/org/apache/hadoop/mapred/ReduceTask.java

+ 3 - 0
CHANGES.txt

@@ -106,6 +106,9 @@ Release 1.1.0 - unreleased
     HADOOP-8154. DNS#getIPs shouldn't silently return the local host
     IP for bogus interface names. (eli)
 
+    MAPREDUCE-3992. Reduce fetcher doesn't verify HTTP status code of response
+    (todd)
+
   IMPROVEMENTS
 
     MAPREDUCE-3597. [Rumen] Provide a way to access other info of history file

+ 10 - 1
src/mapred/org/apache/hadoop/mapred/ReduceTask.java

@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -1482,9 +1483,17 @@ class ReduceTask extends Task {
       throws IOException, InterruptedException {
         // Connect
         URL url = mapOutputLoc.getOutputLocation();
-        URLConnection connection = url.openConnection();
+        HttpURLConnection connection = (HttpURLConnection)url.openConnection();
         
         InputStream input = setupSecureConnection(mapOutputLoc, connection);
+
+        // Validate response code
+        int rc = connection.getResponseCode();
+        if (rc != HttpURLConnection.HTTP_OK) {
+          throw new IOException(
+              "Got invalid response code " + rc + " from " + url +
+              ": " + connection.getResponseMessage());
+        }
  
         // Validate header from map output
         TaskAttemptID mapId = null;