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

Commit ae5e8c6

Browse files
committed
avoid throw/catch when evaluating user attributes
1 parent d3020cc commit ae5e8c6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/launchdarkly/client/LDUser.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ public LDUser(String key) {
7171
}
7272

7373
protected JsonElement getValueForEvaluation(String attribute) {
74-
try {
75-
return UserAttribute.valueOf(attribute).get(this);
76-
} catch (IllegalArgumentException expected) {
77-
return getCustom(attribute);
74+
// Don't use Enum.valueOf because we don't want to trigger unnecessary exceptions
75+
for (UserAttribute builtIn: UserAttribute.values()) {
76+
if (builtIn.name().equals(attribute)) {
77+
return builtIn.get(this);
78+
}
7879
}
80+
return getCustom(attribute);
7981
}
8082

8183
JsonPrimitive getKey() {

0 commit comments

Comments
 (0)