From 5909163aab00a70ecf583254f04e441c97ff17bd Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 29 Jul 2026 14:18:29 +0000
Subject: [PATCH] Remove the never-populated globalArgumentMap from SubCommandArgumentParser (#786)
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
index 06c3b74..495b03b 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -13,7 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
- * Portions Copyright 2018-2024 3A Systems, LLC.
+ * Portions Copyright 2018-2026 3A Systems, LLC.
*/
package com.forgerock.opendj.cli;
@@ -63,8 +63,6 @@
private final Map<Character, Argument> globalShortIDMap = new HashMap<>();
/** The set of global arguments defined for this parser, referenced by long ID. */
private final Map<String, Argument> globalLongIDMap = new HashMap<>();
- /** The set of global arguments defined for this parser, referenced by argument name. */
- private final Map<String, Argument> globalArgumentMap = new HashMap<>();
/** The total set of global arguments defined for this parser. */
private final List<Argument> globalArgumentList = new LinkedList<>();
/** The set of subcommands defined for this parser, referenced by subcommand name. */
@@ -98,7 +96,7 @@
* @return <CODE>true</CODE> if a global argument exists with the specified name, or <CODE>false</CODE> if not.
*/
public boolean hasGlobalArgument(String argumentName) {
- return globalArgumentMap.containsKey(argumentName);
+ return getGlobalArgumentForLongID(formatLongIdentifier(argumentName)) != null;
}
/**
@@ -199,9 +197,6 @@
*/
public void addGlobalArgument(Argument argument, ArgumentGroup group) throws ArgumentException {
String longID = argument.getLongIdentifier();
- if (globalArgumentMap.containsKey(longID)) {
- throw new ArgumentException(ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_NAME.get(longID));
- }
for (SubCommand s : subCommands.values()) {
if (s.getArgumentForLongIdentifier(longID) != null) {
throw new ArgumentException(ERR_SUBCMDPARSER_GLOBAL_ARG_NAME_SUBCMD_CONFLICT.get(
@@ -226,11 +221,9 @@
}
}
- if (!longArgumentsCaseSensitive()) {
- longID = toLowerCase(longID);
- if (globalLongIDMap.containsKey(longID)) {
- throw new ArgumentException(ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_LONG_ID.get(longID));
- }
+ longID = formatLongIdentifier(longID);
+ if (globalLongIDMap.containsKey(longID)) {
+ throw new ArgumentException(ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_LONG_ID.get(longID));
}
for (SubCommand s : subCommands.values()) {
--
Gitblit v1.10.0