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 st...@apache.org on 2022/10/25 17:07:59 UTC
[hadoop] branch trunk updated: HADOOP-18504. Fixed an unhandled NullPointerException in class KeyProvider (#5064)
This is an automated email from the ASF dual-hosted git repository.
stevel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new f140506d675 HADOOP-18504. Fixed an unhandled NullPointerException in class KeyProvider (#5064)
f140506d675 is described below
commit f140506d6756f8d9aaeb728e5309ab27c513f996
Author: FuzzingTeam <11...@users.noreply.github.com>
AuthorDate: Tue Oct 25 22:37:49 2022 +0530
HADOOP-18504. Fixed an unhandled NullPointerException in class KeyProvider (#5064)
Contributed by FuzzingTeam
---
.../src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java | 3 ++-
.../src/test/java/org/apache/hadoop/crypto/key/TestKeyProvider.java | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java
index 4d1674bd7b8..5e207251805 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/key/KeyProvider.java
@@ -639,13 +639,14 @@ public abstract class KeyProvider implements Closeable {
public abstract void flush() throws IOException;
/**
- * Split the versionName in to a base name. Converts "/aaa/bbb/3" to
+ * Split the versionName in to a base name. Converts "/aaa/bbb@3" to
* "/aaa/bbb".
* @param versionName the version name to split
* @return the base name of the key
* @throws IOException raised on errors performing I/O.
*/
public static String getBaseName(String versionName) throws IOException {
+ Objects.requireNonNull(versionName, "VersionName cannot be null");
int div = versionName.lastIndexOf('@');
if (div == -1) {
throw new IOException("No version in key path " + versionName);
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProvider.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProvider.java
index cb6a1fb31e6..b0c3b090022 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProvider.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProvider.java
@@ -36,6 +36,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -62,6 +63,8 @@ public class TestKeyProvider {
} catch (IOException e) {
assertTrue(true);
}
+ intercept(NullPointerException.class, () ->
+ KeyProvider.getBaseName(null));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org