Adding null check...

if (null == newLocalDirs) {
        throw new IOException(contextCfgItemName + " not configured");
      }



Testcase..


/*
+   * Test when dfs.client.buffer.dir not configured and called
+   * getLocalPathForWrite
+   */
+  @Test
+  public void testShouldNotthrowNPE() throws Exception {
+
+    Configuration conf1 = new Configuration();
+    try {
+      dirAllocator.getLocalPathForWrite("/test", conf1);
+      fail("not throwing the exception");
+    } catch (IOException e) {
+      assertEquals("Incorrect exception message",
+          CONTEXT+" not configured", e.getMessage());
+    }
+  }
 }

--
View this message in context: 
http://lucene.472066.n3.nabble.com/jira-Created-HADOOP-8436-NPE-In-getLocalPathForWrite-path-conf-when-dfs-client-buffer-dir-not-configd-tp3986032p3986442.html
Sent from the Hadoop lucene-dev mailing list archive at Nabble.com.

Reply via email to