You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by we...@apache.org on 2018/07/16 22:46:56 UTC
hadoop git commit: HDFS-13485. DataNode WebHDFS endpoint throws NPE.
Contributed by Siyao Meng.
Repository: hadoop
Updated Branches:
refs/heads/trunk 121865c3f -> d21535771
HDFS-13485. DataNode WebHDFS endpoint throws NPE. Contributed by Siyao Meng.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d2153577
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d2153577
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d2153577
Branch: refs/heads/trunk
Commit: d2153577181f900ee6d8bf67d254e408bbaad243
Parents: 121865c
Author: Wei-Chiu Chuang <we...@apache.org>
Authored: Mon Jul 16 15:45:55 2018 -0700
Committer: Wei-Chiu Chuang <we...@apache.org>
Committed: Mon Jul 16 15:45:55 2018 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/security/token/Token.java | 5 +++++
.../apache/hadoop/security/token/TestToken.java | 18 ++++++++++++++++++
2 files changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d2153577/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
index 33cb9ec..25aac88 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/Token.java
@@ -23,6 +23,7 @@ import com.google.protobuf.ByteString;
import com.google.common.primitives.Bytes;
import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
@@ -358,6 +359,10 @@ public class Token<T extends TokenIdentifier> implements Writable {
*/
private static void decodeWritable(Writable obj,
String newValue) throws IOException {
+ if (newValue == null) {
+ throw new HadoopIllegalArgumentException(
+ "Invalid argument, newValue is null");
+ }
Base64 decoder = new Base64(0, null, true);
DataInputBuffer buf = new DataInputBuffer();
byte[] decoded = decoder.decode(newValue);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d2153577/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/TestToken.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/TestToken.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/TestToken.java
index f6e5133..3a3567c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/TestToken.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/token/TestToken.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.security.token;
import java.io.*;
import java.util.Arrays;
+import org.apache.hadoop.HadoopIllegalArgumentException;
import org.apache.hadoop.io.*;
import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier;
@@ -100,6 +101,23 @@ public class TestToken {
}
}
+ /*
+ * Test decodeWritable() with null newValue string argument,
+ * should throw HadoopIllegalArgumentException.
+ */
+ @Test
+ public void testDecodeWritableArgSanityCheck() throws Exception {
+ Token<AbstractDelegationTokenIdentifier> token =
+ new Token<AbstractDelegationTokenIdentifier>();
+ try {
+ token.decodeFromUrlString(null);
+ fail("Should have thrown HadoopIllegalArgumentException");
+ }
+ catch (HadoopIllegalArgumentException e) {
+ Token.LOG.info("Test decodeWritable() sanity check success.");
+ }
+ }
+
@Test
public void testDecodeIdentifier() throws IOException {
TestDelegationTokenSecretManager secretManager =
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org