mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Add fallback to support old not updated clients
If a updated client makes a param change request old client do not recognize that enum. To avoid exceptions ro null pointers we fall back to the UNDEFINED enum entry if available. As param value we show an empty string. Beside that issue no problems have been found so far with adding a new param entry.
This commit is contained in:
parent
adad426797
commit
a10ce23145
2 changed files with 6 additions and 4 deletions
|
@ -69,9 +69,10 @@ public class ProtoUtil {
|
|||
E result = Enums.getIfPresent(enumType, name).orNull();
|
||||
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.
|
||||
result = Enums.getIfPresent(enumType, "UNDEFINED").orNull();
|
||||
log.error("We try to lookup for an enum entry with name 'UNDEFINED' and use that if available, " +
|
||||
"otherwise the enum is null. enum={}", result);
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,8 @@ public class BsqFormatter extends BSFormatter {
|
|||
public String formatParamValue(Param param, String value) {
|
||||
switch (param.getParamType()) {
|
||||
case UNDEFINED:
|
||||
throw new IllegalArgumentException("ParamType UNDEFINED. param: " + param);
|
||||
// In case we add a new param old clients will not know that enum and fall back to UNDEFINED.
|
||||
return "";
|
||||
case BSQ:
|
||||
return formatCoinWithCode(parseToCoin(value));
|
||||
case BTC:
|
||||
|
|
Loading…
Add table
Reference in a new issue