jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1580003 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/spi/security/ test/java/org/apache/jackrabbit/oak/security/ test/java/org/apache/jackrabbit/oak/spi/security/
Date Fri, 21 Mar 2014 18:10:18 GMT
Author: angela
Date: Fri Mar 21 18:10:17 2014
New Revision: 1580003

URL: http://svn.apache.org/r1580003
Log:
OAK-1593 : Guard against NPE in ConfigurationParameters.of(ConfigurationParameters...)

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java
      - copied, changed from r1579994, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java?rev=1580003&r1=1580002&r2=1580003&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
Fri Mar 21 18:10:17 2014
@@ -83,7 +83,9 @@ public final class ConfigurationParamete
     public static ConfigurationParameters of(@Nonnull ConfigurationParameters... params)
{
         Map<String, Object> m = new HashMap<String, Object>();
         for (ConfigurationParameters cp : params) {
-            m.putAll(cp.options);
+            if (cp != null) {
+                m.putAll(cp.options);
+            }
         }
         return m.isEmpty() ? EMPTY : new ConfigurationParameters(m);
     }

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java
(from r1579994, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java&r1=1579994&r2=1580003&rev=1580003&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParametersTest.java
Fri Mar 21 18:10:17 2014
@@ -14,14 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.security;
+package org.apache.jackrabbit.oak.spi.security;
 
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,6 +32,7 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertTrue;
 import static junit.framework.Assert.fail;
 import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertSame;
 
 public class ConfigurationParametersTest {
 
@@ -43,6 +43,24 @@ public class ConfigurationParametersTest
     public void tearDown() {}
 
     @Test
+    public void testCreation() {
+        ConfigurationParameters params = ConfigurationParameters.of(
+                ConfigurationParameters.EMPTY,
+                null,
+                ConfigurationParameters.of(Collections.singletonMap("a", "a")));
+        assertFalse(params.isEmpty());
+        assertEquals(1, params.size());
+        assertTrue(params.contains("a"));
+    }
+
+    @Test
+    public void testCreationFromNull() {
+        ConfigurationParameters cp = null;
+        ConfigurationParameters params = ConfigurationParameters.of(new ConfigurationParameters[]
{cp});
+        assertSame(ConfigurationParameters.EMPTY, params);
+    }
+
+    @Test
     public void testContains() {
         ConfigurationParameters params = ConfigurationParameters.EMPTY;
         assertFalse(params.contains("some"));



Mime
View raw message