diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index 3aab95e9f7..d808b529a6 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -367,21 +367,19 @@ private static Map getOptionGroup() { * set parameters. */ public static void setParam(final String[] args, final String confFileName) { - Config config = Configuration.getByFileName(PARAMETER.shellConfFileName, confFileName); - setParam(args, config); - } - - /** - * set parameters. - */ - public static void setParam(final String[] args, final Config config) { - JCommander.newBuilder().addObject(PARAMETER).build().parse(args); if (PARAMETER.version) { printVersion(); ExitManager.getInstance().exit(ExitReason.NORMAL_SHUTDOWN); } + Config config = Configuration.getByFileName(PARAMETER.shellConfFileName, confFileName); + setParam(config); + } + /** + * set parameters. + */ + public static void setParam(final Config config) { if (config.hasPath(Constant.NET_TYPE) && Constant.TESTNET.equalsIgnoreCase(config.getString(Constant.NET_TYPE))) { Wallet.setAddressPreFixByte(Constant.ADD_PRE_FIX_BYTE_TESTNET); diff --git a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java index 87933a62e5..6ee52ca009 100644 --- a/framework/src/test/java/org/tron/core/config/args/ArgsTest.java +++ b/framework/src/test/java/org/tron/core/config/args/ArgsTest.java @@ -162,7 +162,7 @@ public void testInitService() { storage.put("storage.db.directory", "database"); Config config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); // test default value - Args.setParam(new String[] {}, config); + Args.setParam(config); Assert.assertTrue(Args.getInstance().isRpcEnable()); Assert.assertTrue(Args.getInstance().isRpcSolidityEnable()); Assert.assertTrue(Args.getInstance().isRpcPBFTEnable()); @@ -185,7 +185,7 @@ public void testInitService() { storage.put("node.jsonrpc.httpPBFTEnable", "true"); config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); // test value - Args.setParam(new String[] {}, config); + Args.setParam(config); Assert.assertTrue(Args.getInstance().isRpcEnable()); Assert.assertTrue(Args.getInstance().isRpcSolidityEnable()); Assert.assertTrue(Args.getInstance().isRpcPBFTEnable()); @@ -208,7 +208,7 @@ public void testInitService() { storage.put("node.jsonrpc.httpPBFTEnable", "false"); config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); // test value - Args.setParam(new String[] {}, config); + Args.setParam(config); Assert.assertFalse(Args.getInstance().isRpcEnable()); Assert.assertFalse(Args.getInstance().isRpcSolidityEnable()); Assert.assertFalse(Args.getInstance().isRpcPBFTEnable()); @@ -231,7 +231,7 @@ public void testInitService() { storage.put("node.jsonrpc.httpPBFTEnable", "true"); config = ConfigFactory.defaultOverrides().withFallback(ConfigFactory.parseMap(storage)); // test value - Args.setParam(new String[] {}, config); + Args.setParam(config); Assert.assertFalse(Args.getInstance().isRpcEnable()); Assert.assertFalse(Args.getInstance().isRpcSolidityEnable()); Assert.assertTrue(Args.getInstance().isRpcPBFTEnable());