Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 2 files changed
  • 0 comments
  • 2 contributors
Dec 10, 2011
Matt Hall Don't throw NPE on null value puts to properties. 0d905f8
Dec 13, 2011
Arin Sarkissian Merge pull request #1 from Docracy/master
Don't throw Null Pointer when adding null values to properties
272d993
6  src/main/java/com/jeraff/kissmetrics/client/KissMetricsProperties.java
@@ -6,8 +6,10 @@
6 6
     private StringBuilder sb = new StringBuilder();
7 7
 
8 8
     private void _put(String key, Object value) {
9  
-        sb.append(URLUTF8Encoder.encode(key)).append("=").append(URLUTF8Encoder.encode(value.toString()))
10  
-          .append("&");
  9
+        if (value != null) {
  10
+            sb.append(URLUTF8Encoder.encode(key)).append("=").append(URLUTF8Encoder.encode(value.toString()))
  11
+              .append("&");
  12
+        }
11 13
     }
12 14
 
13 15
     public KissMetricsProperties put(String key, String value) {
6  src/test/java/com/jeraff/kissmetrics/client/KissMetricsPropertiesTest.java
@@ -13,4 +13,10 @@ public void testPutSafe() throws Exception {
13 13
         Assert.assertEquals(-1, props.getQueryString().indexOf("event1"));
14 14
         Assert.assertTrue(props.getQueryString().indexOf("event2") >= 0);
15 15
     }
  16
+
  17
+    @Test
  18
+    public void testPutNulls() throws Exception {
  19
+        KissMetricsProperties props = new KissMetricsProperties();
  20
+        props.put("test", null);
  21
+    }
16 22
 }

No commit comments for this range

Something went wrong with that request. Please try again.