This commit is contained in:
Manfred Karrer 2018-12-02 14:53:57 +01:00
parent 2ba21f0277
commit a6eedf97c5
No known key found for this signature in database
GPG key ID: 401250966A6B2C46

View file

@ -67,9 +67,12 @@ public class ProtoUtil {
@Nullable
public static <E extends Enum<E>> E enumFromProto(Class<E> enumType, String name) {
E result = Enums.getIfPresent(enumType, name).orNull();
if (result == null)
if (result == null) {
log.error("Invalid value for enum " + enumType.getSimpleName() + ": " + name);
// TODO returning null here can cause problems in caller. Maybe we should throw an exception? Or maybe
// better to ensure that enums have always a default value with represents an undefined state and we fall
// back to that.
}
return result;
}