ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [08/11] ignite git commit: IGNITE-3274: Hadoop: Fixed NPE in BasicUserNameMapper.
Date Wed, 08 Jun 2016 12:19:49 GMT
IGNITE-3274: Hadoop: Fixed NPE in BasicUserNameMapper.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/42739504
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/42739504
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/42739504

Branch: refs/heads/master
Commit: 4273950458a9bb2f83d5fc0489da49aa1fa1dfaf
Parents: c300448
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Jun 8 11:50:22 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Jun 8 14:57:56 2016 +0300

----------------------------------------------------------------------
 .../ignite/hadoop/util/BasicUserNameMapper.java  |  4 +---
 .../hadoop/util/BasicUserNameMapperSelfTest.java | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/42739504/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
index aea7196..c34808a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/util/BasicUserNameMapper.java
@@ -41,9 +41,7 @@ public class BasicUserNameMapper implements UserNameMapper {
 
     /** {@inheritDoc} */
     @Nullable @Override public String map(String name) {
-        assert mappings != null;
-
-        String res = mappings.get(name);
+        String res = mappings != null ? mappings.get(name) : null;
 
         return res != null ? res : useDfltUsrName ? dfltUsrName : name;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/42739504/modules/hadoop/src/test/java/org/apache/ignite/hadoop/util/BasicUserNameMapperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/util/BasicUserNameMapperSelfTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/util/BasicUserNameMapperSelfTest.java
index 54b03f9..fd8fdef 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/util/BasicUserNameMapperSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/util/BasicUserNameMapperSelfTest.java
@@ -28,13 +28,30 @@ import java.util.Map;
  */
 public class BasicUserNameMapperSelfTest extends GridCommonAbstractTest {
     /**
+     * Test null mappings.
+     *
+     * @throws Exception If failed.
+     */
+    public void testNullMappings() throws Exception {
+        checkNullOrEmptyMappings(null);
+    }
+
+    /**
      * Test empty mappings.
      *
      * @throws Exception If failed.
      */
     public void testEmptyMappings() throws Exception {
-        Map<String, String> map = new HashMap<>();
+        checkNullOrEmptyMappings(new HashMap<String, String>());
+    }
 
+    /**
+     * Check null or empty mappings.
+     *
+     * @param map Mappings.
+     * @throws Exception If failed.
+     */
+    private void checkNullOrEmptyMappings(@Nullable Map<String, String> map) throws
Exception {
         BasicUserNameMapper mapper = create(map, false, null);
 
         assertNull(mapper.map(null));


Mime
View raw message