From 817be26c17cc69443a35bd8e5923d22e3b26a570 Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Fri, 24 Jan 2014 06:27:40 +0000 Subject: [PATCH] HADOOP-10248. Property name should be included in the exception where property value is null. Contributed by Akira AJISAKA. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1560906 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/conf/Configuration.java | 2 +- .../test/java/org/apache/hadoop/conf/TestConfiguration.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 2e5a435b79..4d18a94c4a 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -556,6 +556,9 @@ Release 2.3.0 - UNRELEASED HADOOP-10132. RPC#stopProxy() should log the class of proxy when IllegalArgumentException is encountered (Ted yu via umamahesh) + HADOOP-10248. Property name should be included in the exception where property value + is null (Akira AJISAKA via umamahesh) + OPTIMIZATIONS HADOOP-10142. Avoid groups lookup for unprivileged users such as "dr.who" diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java index 456a8d2cf1..c0d82004c0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java @@ -963,7 +963,7 @@ public void set(String name, String value, String source) { "Property name must not be null"); Preconditions.checkArgument( value != null, - "Property value must not be null"); + "The value of property " + name + " must not be null"); DeprecationContext deprecations = deprecationContext.get(); if (deprecations.getDeprecatedKeyMap().isEmpty()) { getProps(); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index 87ebb61f49..1ce0b01085 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -1183,6 +1183,8 @@ public void testSettingValueNull() throws Exception { fail("Should throw an IllegalArgumentException exception "); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); + assertEquals(e.getMessage(), + "The value of property testClassName must not be null"); } } @@ -1193,6 +1195,7 @@ public void testSettingKeyNull() throws Exception { fail("Should throw an IllegalArgumentException exception "); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); + assertEquals(e.getMessage(), "Property name must not be null"); } }