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/trunk@1302754 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-03-20 02:28:53 +00:00
parent 21426e6e42
commit 04a47dea74
2 changed files with 13 additions and 1 deletions

View File

@ -160,6 +160,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-4010. TestWritableJobConf fails on trunk (tucu via bobby)
MAPREDUCE-3992. Reduce fetcher doesn't verify HTTP status code of response
(todd)
Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.URLConnection;
import java.util.HashSet;
import java.util.List;
@ -204,7 +205,7 @@ class Fetcher<K,V> extends Thread {
try {
URL url = getMapOutputURL(host, maps);
URLConnection connection = url.openConnection();
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
// generate hash of the url
String msgToEncode = SecureShuffleUtils.buildMsgFrom(url);
@ -218,6 +219,14 @@ class Fetcher<K,V> extends Thread {
connect(connection, connectionTimeout);
connectSucceeded = true;
input = new DataInputStream(connection.getInputStream());
// Validate response code
int rc = connection.getResponseCode();
if (rc != HttpURLConnection.HTTP_OK) {
throw new IOException(
"Got invalid response code " + rc + " from " + url +
": " + connection.getResponseMessage());
}
// get the replyHash which is HMac of the encHash we sent to the server
String replyHash = connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);