Skip to content

Commit 998779e

Browse files
committed
refactor(config): drop replaceNullWithEmpty workaround
Address PR review from lxcmyf (2026-04-22, NodeConfig.java:370). The `replaceNullWithEmpty` helper was originally a compatibility shim for system-test configs that write `discovery.external.ip = null`. Rather than generalizing the shim over all paths (the reviewer's concern), remove it entirely and let ConfigBeanFactory fail fast on HOCON null values. The auto-binding itself is the right safety net: any String-typed field that receives `= null` from an external config surfaces at startup as `ConfigBeanFactory.ValidationFailed` naming the exact path. That's the correct long-term signal that the external config needs to use `""` or remove the key, not to be papered over. No in-repo configs write `= null`; external configs (system-test) should update their own defaults.
1 parent f7bd20f commit 998779e

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

common/src/main/java/org/tron/core/config/args/NodeConfig.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,9 @@ public static class DnsConfig {
362362
public static NodeConfig fromConfig(Config config) {
363363
Config section = config.getConfig("node");
364364

365-
// Replace null values with empty strings before bean binding.
366-
// Some external configs (e.g. system-test) set "discovery.external.ip = null"
367-
// which ConfigBeanFactory cannot bind to a String field.
368-
// Note: hasPath() returns false for null values, use hasPathOrNull() instead.
369-
section = replaceNullWithEmpty(section, "discovery.external.ip");
370-
section = replaceNullWithEmpty(section, "trustNode");
371-
372-
// Auto-bind all fields and sub-beans
365+
// Auto-bind all fields and sub-beans. ConfigBeanFactory fails fast with a
366+
// descriptive path on any `= null` value — external configs that use the
367+
// HOCON null keyword should fix their config rather than rely on silent coercion.
373368
NodeConfig nc = ConfigBeanFactory.create(section, NodeConfig.class);
374369

375370
// isOpenFullTcpDisconnect: boolean "is" prefix breaks JavaBean pairing
@@ -500,14 +495,4 @@ private static String getString(Config config, String path, String defaultValue)
500495
return config.hasPath(path) ? config.getString(path) : defaultValue;
501496
}
502497

503-
// Replace a null config value with empty string so ConfigBeanFactory can bind it.
504-
// hasPath() returns false for null values; hasPathOrNull() returns true.
505-
private static Config replaceNullWithEmpty(Config config, String path) {
506-
if (config.hasPathOrNull(path) && config.getIsNull(path)) {
507-
return config.withValue(path,
508-
com.typesafe.config.ConfigValueFactory.fromAnyRef(""));
509-
}
510-
return config;
511-
}
512-
513498
}

0 commit comments

Comments
 (0)