Skip to content

Commit

Permalink
Make extension-metadata enum parsing resilient to new values
Browse files Browse the repository at this point in the history
(cherry picked from commit 3193d7c)
  • Loading branch information
ia3andy authored and gsmet committed Dec 1, 2021
1 parent d8644a6 commit 958821e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public <T extends Enum<T>> T toEnum(Class<T> clazz, T defaultValue) {
if (name == null) {
return defaultValue;
}
return T.valueOf(clazz, name.toUpperCase(Locale.ROOT).replace('-', '_'));
try {
return T.valueOf(clazz, name.toUpperCase(Locale.ROOT).replace('-', '_'));
} catch (IllegalArgumentException e) {
return defaultValue;
}
}

}

0 comments on commit 958821e

Please sign in to comment.