diff --git a/src/main/java/com/launchdarkly/client/LDUser.java b/src/main/java/com/launchdarkly/client/LDUser.java index 95209dc90..a36025f2d 100644 --- a/src/main/java/com/launchdarkly/client/LDUser.java +++ b/src/main/java/com/launchdarkly/client/LDUser.java @@ -71,10 +71,14 @@ public LDUser(String key) { } protected JsonElement getValueForEvaluation(String attribute) { + JsonElement returnVal = getCustom(attribute); + if (returnVal != null) { + return returnVal; + } try { return UserAttribute.valueOf(attribute).get(this); } catch (IllegalArgumentException expected) { - return getCustom(attribute); + return null; } } @@ -127,7 +131,7 @@ JsonPrimitive getAnonymous() { } JsonElement getCustom(String key) { - if (custom != null) { + if (custom != null && !custom.isEmpty()) { return custom.get(key); } return null;