Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Fix potential NPEs in building Users
Browse files Browse the repository at this point in the history
  • Loading branch information
jkodumal committed Nov 5, 2015
1 parent ac3fcb2 commit a3dbb7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {

allprojects {
group = 'com.launchdarkly'
version = "0.14.0"
version = "0.15.0-SNAPSHOT"
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/launchdarkly/client/LDUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ public Builder email(String email) {
* @return the builder
*/
public Builder custom(String k, String v) {
custom.put(k, new JsonPrimitive(v));
if (key != null && v != null) {
custom.put(k, new JsonPrimitive(v));
}
return this;
}

Expand All @@ -265,7 +267,9 @@ public Builder custom(String k, String v) {
* @return the builder
*/
public Builder custom(String k, Number n) {
custom.put(k, new JsonPrimitive(n));
if (key != null && n != null) {
custom.put(k, new JsonPrimitive(n));
}
return this;
}

Expand All @@ -276,7 +280,9 @@ public Builder custom(String k, Number n) {
* @return the builder
*/
public Builder custom(String k, Boolean b) {
custom.put(k, new JsonPrimitive(b));
if (key != null && b != null) {
custom.put(k, new JsonPrimitive(b));
}
return this;
}

Expand All @@ -289,7 +295,9 @@ public Builder custom(String k, Boolean b) {
public Builder custom(String k, List<String> vs) {
JsonArray array = new JsonArray();
for (String v : vs) {
array.add(new JsonPrimitive(v));
if (v != null) {
array.add(new JsonPrimitive(v));
}
}
custom.put(k, array);
return this;
Expand Down

0 comments on commit a3dbb7b

Please sign in to comment.