diff --git a/server/src/main/java/org/jboss/as/server/Main.java b/server/src/main/java/org/jboss/as/server/Main.java index c072e76b014..3f0149c33dc 100644 --- a/server/src/main/java/org/jboss/as/server/Main.java +++ b/server/src/main/java/org/jboss/as/server/Main.java @@ -323,45 +323,48 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope // do nothing, just need to filter out as Windows batch scripts cannot filter it out } else if(arg.startsWith(CommandLineConstants.GIT_REPO)) { int idx = arg.indexOf("="); + if (idx == arg.length() - 1) { + return requireValue(arg, productConfig); + } if (idx == -1) { final int next = i + 1; if (next < argsLength) { gitRepository = args[next]; i++; } else { - STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(productConfig); - return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + return requireValue(arg, productConfig); } } else { gitRepository = arg.substring(idx + 1); } } else if(arg.startsWith(CommandLineConstants.GIT_AUTH)) { int idx = arg.indexOf("="); + if (idx == arg.length() - 1) { + return requireValue(arg, productConfig); + } if (idx == -1) { final int next = i + 1; if (next < argsLength) { gitAuthConfiguration = args[next]; i++; } else { - STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(productConfig); - return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + return requireValue(arg, productConfig); } } else { gitAuthConfiguration = arg.substring(idx + 1); } } else if(arg.startsWith(CommandLineConstants.GIT_BRANCH)) { int idx = arg.indexOf("="); + if (idx == arg.length() - 1) { + return requireValue(arg, productConfig); + } if (idx == -1) { final int next = i + 1; if (next < argsLength) { gitBranch = args[next]; i++; } else { - STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(productConfig); - return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + return requireValue(arg, productConfig); } } else { gitBranch = arg.substring(idx + 1); @@ -375,15 +378,16 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope } else if(ConfigurationExtensionFactory.isConfigurationExtensionSupported() && ConfigurationExtensionFactory.commandLineContainsArgument(arg)) { int idx = arg.indexOf("="); + if (idx == arg.length() - 1) { + return requireValue(arg, productConfig); + } if (idx == -1) { final int next = i + 1; if (next < argsLength) { supplementalConfiguration = args[next]; i++; } else { - STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(productConfig); - return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + return requireValue(arg, productConfig); } } else { supplementalConfiguration = arg.substring(idx + 1); @@ -394,9 +398,7 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope return new ServerEnvironmentWrapper (ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); } } catch (IndexOutOfBoundsException e) { - STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); - usage(productConfig); - return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + return requireValue(arg, productConfig); } } @@ -408,6 +410,12 @@ public static ServerEnvironmentWrapper determineEnvironment(String[] args, Prope startGracefully, gitRepository, gitBranch, gitAuthConfiguration, supplementalConfiguration)); } + private static ServerEnvironmentWrapper requireValue(String arg, ProductConfig productConfig) { + STDERR.println(ServerLogger.ROOT_LOGGER.valueExpectedForCommandLineOption(arg)); + usage(productConfig); + return new ServerEnvironmentWrapper(ServerEnvironmentWrapper.ServerEnvironmentStatus.ERROR); + } + private static void assertSingleConfig(String serverConfig) { if (serverConfig != null) { throw ServerLogger.ROOT_LOGGER.cannotHaveBothInitialServerConfigAndServerConfig();