From 2b747cc32385123fde4cbfbdc83ff62f879c7f9f Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Tue, 22 Sep 2020 18:48:47 -0500 Subject: [PATCH] Don't return null if name is null by try to use UNDEFINED. Only if that is not present we return null --- common/src/main/java/bisq/common/proto/ProtoUtil.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/bisq/common/proto/ProtoUtil.java b/common/src/main/java/bisq/common/proto/ProtoUtil.java index 5f79abe02a..f734526534 100644 --- a/common/src/main/java/bisq/common/proto/ProtoUtil.java +++ b/common/src/main/java/bisq/common/proto/ProtoUtil.java @@ -69,13 +69,10 @@ public class ProtoUtil { */ @Nullable public static > E enumFromProto(Class enumType, String name) { - if (name == null) { - return null; - } - - E result = Enums.getIfPresent(enumType, name).orNull(); + String enumName = name != null ? name : "UNDEFINED"; + E result = Enums.getIfPresent(enumType, enumName).orNull(); if (result == null) { - log.debug("Invalid value for enum " + enumType.getSimpleName() + ": " + name); + log.debug("Invalid value for enum " + enumType.getSimpleName() + ": " + enumName); result = Enums.getIfPresent(enumType, "UNDEFINED").orNull(); log.debug("We try to lookup for an enum entry with name 'UNDEFINED' and use that if available, " + "otherwise the enum is null. enum={}", result);