ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [20/24] ignite git commit: IGNITE-3274: Hadoop: Fixed NPE in BasicUserNameMapper.
Date Fri, 10 Jun 2016 06:10:42 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/ccbb059a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ccbb059a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ccbb059a

Branch: refs/heads/ignite-3038
Commit: ccbb059a1d89ec631a4c1c85bd0d242ba21d2579
Parents: 065d2e7
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 11:50:22 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/ccbb059a/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/ccbb059a/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