Skip to content

Commit

Permalink
Merge pull request #5 from kissmetrics/NullPropertyValue-fix
Browse files Browse the repository at this point in the history
Adds a check for null property values during property encoding
  • Loading branch information
willrust committed May 13, 2014
2 parents 42baea7 + 5aab796 commit 07a3748
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions KISSmetricsAPI/src/com/kissmetrics/sdk/QueryEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public String encodeProperties(final HashMap<String, String> properties) {

// Check for valid value
String stringValue = properties.get(stringKey);
if (stringValue.length() == 0) {
if (stringValue == null || stringValue.length() == 0) {
Log.w("KISSmetricsAPI",
"Property values must not be empty strings. Dropping property.");
"Property values must not be null or empty strings. Dropping property.");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ public final void test_urlEncodeProperties() {
assertEquals("urlEncodeProperties yields expected URL", expectedEncodedProperties, encodedProperties);
}


public final void test_urlEncodePropertiesDropsNullValues() {

HashMap<String, String> testPropertyHashMap = new HashMap<String, String>();
testPropertyHashMap.put("Reserved", null);

String encodedProperties = cut.encodeProperties(testPropertyHashMap);

String expectedEncodedProperties = "";

assertEquals("urlEncodeProperties drops null property values", expectedEncodedProperties, encodedProperties);
}


public final void test_createEventQueryWithProperties() {

Expand Down
Binary file modified KISSmetricsSDK.jar
Binary file not shown.

0 comments on commit 07a3748

Please sign in to comment.