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
  • Loading branch information
ia3andy committed Sep 22, 2021
1 parent 5b91e61 commit 3193d7c
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 3193d7c

Please sign in to comment.