HDFS-3490. DatanodeWebHdfsMethods throws NullPointerException if NamenodeRpcAddressParam is not set.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1348287 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
51d889e369
commit
5991ed9cbd
|
@ -305,6 +305,9 @@ Branch-2 ( Unreleased changes )
|
|||
|
||||
HDFS-3243. TestParallelRead timing out on jenkins. (Henry Robinson via todd)
|
||||
|
||||
HDFS-3490. DatanodeWebHdfsMethods throws NullPointerException if
|
||||
NamenodeRpcAddressParam is not set. (szetszwo)
|
||||
|
||||
BREAKDOWN OF HDFS-3042 SUBTASKS
|
||||
|
||||
HDFS-2185. HDFS portion of ZK-based FailoverController (todd)
|
||||
|
|
|
@ -98,6 +98,10 @@ public class DatanodeWebHdfsMethods {
|
|||
LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
|
||||
+ ", ugi=" + ugi + Param.toSortedString(", ", parameters));
|
||||
}
|
||||
if (nnRpcAddr == null) {
|
||||
throw new IllegalArgumentException(NamenodeRpcAddressParam.NAME
|
||||
+ " is not specified.");
|
||||
}
|
||||
|
||||
//clear content type
|
||||
response.setContentType(null);
|
||||
|
|
|
@ -123,7 +123,7 @@ public class NamenodeWebHdfsMethods {
|
|||
final DelegationParam delegation,
|
||||
final UserParam username, final DoAsParam doAsUser,
|
||||
final UriFsPathParam path, final HttpOpParam<?> op,
|
||||
final Param<?, ?>... parameters) throws IOException {
|
||||
final Param<?, ?>... parameters) {
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
|
||||
+ ", ugi=" + ugi + ", " + username + ", " + doAsUser
|
||||
|
@ -532,7 +532,7 @@ public class NamenodeWebHdfsMethods {
|
|||
final RenewerParam renewer,
|
||||
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
||||
final BufferSizeParam bufferSize
|
||||
) throws IOException, URISyntaxException, InterruptedException {
|
||||
) throws IOException, InterruptedException {
|
||||
return get(ugi, delegation, username, doAsUser, ROOT, op,
|
||||
offset, length, renewer, bufferSize);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ abstract class InetSocketAddressParam
|
|||
|
||||
@Override
|
||||
InetSocketAddress parse(final String str) {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("The input string is null: expect "
|
||||
+ getDomain());
|
||||
}
|
||||
final int i = str.indexOf(':');
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("Failed to parse \"" + str
|
||||
|
|
|
@ -59,7 +59,7 @@ abstract class LongParam extends Param<Long, LongParam.Domain> {
|
|||
|
||||
@Override
|
||||
public String getDomain() {
|
||||
return "<" + NULL + " | short in radix " + radix + ">";
|
||||
return "<" + NULL + " | long in radix " + radix + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +72,7 @@ abstract class LongParam extends Param<Long, LongParam.Domain> {
|
|||
}
|
||||
}
|
||||
|
||||
/** Convert a Short to a String. */
|
||||
/** Convert a Long to a String. */
|
||||
String toString(final Long n) {
|
||||
return n == null? NULL: Long.toString(n, radix);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|||
import org.apache.hadoop.hdfs.web.resources.DoAsParam;
|
||||
import org.apache.hadoop.hdfs.web.resources.GetOpParam;
|
||||
import org.apache.hadoop.hdfs.web.resources.HttpOpParam;
|
||||
import org.apache.hadoop.hdfs.web.resources.NamenodeRpcAddressParam;
|
||||
import org.apache.hadoop.hdfs.web.resources.PutOpParam;
|
||||
import org.apache.hadoop.security.AccessControlException;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
|
@ -351,5 +352,31 @@ public class TestWebHdfsFileSystemContract extends FileSystemContractBaseTest {
|
|||
{//test append.
|
||||
AppendTestUtil.testAppend(fs, new Path(dir, "append"));
|
||||
}
|
||||
|
||||
{//test NamenodeRpcAddressParam not set.
|
||||
final HttpOpParam.Op op = PutOpParam.Op.CREATE;
|
||||
final URL url = webhdfs.toUrl(op, dir);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod(op.getType().toString());
|
||||
conn.setDoOutput(false);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.connect();
|
||||
final String redirect = conn.getHeaderField("Location");
|
||||
conn.disconnect();
|
||||
|
||||
//remove NamenodeRpcAddressParam
|
||||
WebHdfsFileSystem.LOG.info("redirect = " + redirect);
|
||||
final int i = redirect.indexOf(NamenodeRpcAddressParam.NAME);
|
||||
final int j = redirect.indexOf("&", i);
|
||||
String modified = redirect.substring(0, i - 1) + redirect.substring(j);
|
||||
WebHdfsFileSystem.LOG.info("modified = " + modified);
|
||||
|
||||
//connect to datanode
|
||||
conn = (HttpURLConnection)new URL(modified).openConnection();
|
||||
conn.setRequestMethod(op.getType().toString());
|
||||
conn.setDoOutput(op.getDoOutput());
|
||||
conn.connect();
|
||||
assertEquals(HttpServletResponse.SC_BAD_REQUEST, conn.getResponseCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue