From 946f4e47be62f710458e1adf29745301e0e7c95a Mon Sep 17 00:00:00 2001 From: Steven Massaro Date: Thu, 10 Oct 2024 12:12:56 -0600 Subject: [PATCH] improve startup performance (DAT-18327) (#6366) --- .../integration/commandline/LiquibaseCommandLine.java | 3 ++- .../command/core/helpers/AbstractChangelogCommandStep.java | 5 ++--- .../src/main/java/liquibase/util/StringUtil.java | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/liquibase-cli/src/main/java/liquibase/integration/commandline/LiquibaseCommandLine.java b/liquibase-cli/src/main/java/liquibase/integration/commandline/LiquibaseCommandLine.java index 90a981b923b..18c1bd5f8dd 100644 --- a/liquibase-cli/src/main/java/liquibase/integration/commandline/LiquibaseCommandLine.java +++ b/liquibase-cli/src/main/java/liquibase/integration/commandline/LiquibaseCommandLine.java @@ -898,6 +898,7 @@ protected ClassLoader configureClassLoader() throws IllegalArgumentException { private void addSubcommand(CommandDefinition commandDefinition, CommandLine rootCommand) { List commandNames = expandCommandNames(commandDefinition); + Boolean showHidden = LiquibaseCommandLineConfiguration.SHOW_HIDDEN_ARGS.getCurrentValue(); boolean showCommand = true; for (String[] commandName : commandNames) { @@ -991,7 +992,7 @@ private void addSubcommand(CommandDefinition commandDefinition, CommandLine root if (i > 0) { builder.hidden(true); } else { - builder.hidden(def.getHidden() && !LiquibaseCommandLineConfiguration.SHOW_HIDDEN_ARGS.getCurrentValue()); + builder.hidden(def.getHidden() && !showHidden); } subCommandSpec.addOption(builder.build()); diff --git a/liquibase-standard/src/main/java/liquibase/command/core/helpers/AbstractChangelogCommandStep.java b/liquibase-standard/src/main/java/liquibase/command/core/helpers/AbstractChangelogCommandStep.java index abe6b49e5a1..48548b7e38d 100644 --- a/liquibase-standard/src/main/java/liquibase/command/core/helpers/AbstractChangelogCommandStep.java +++ b/liquibase-standard/src/main/java/liquibase/command/core/helpers/AbstractChangelogCommandStep.java @@ -8,7 +8,6 @@ import liquibase.command.CommandBuilder; import liquibase.command.CommandScope; import liquibase.exception.CommandValidationException; -import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Arrays; @@ -33,7 +32,7 @@ public abstract class AbstractChangelogCommandStep extends AbstractCommandStep { .defaultValue("none").description("Sets runOnChange=\"true\" for changesets containing solely changes of these types (e. g. createView, createProcedure, ...).").build(); REPLACE_IF_EXISTS_TYPES_ARG = builder.argument("replaceIfExistsTypes", String.class) .defaultValue("none") - .description(String.format("Sets replaceIfExists=\"true\" for changes of these types (supported types: %s)", StringUtils.join(REPLACE_IF_EXISTS_TYPES_NAMES, ", "))).build(); + .description("Sets replaceIfExists=\"true\" for changes of these types (supported types: createProcedure, createView)").build(); SKIP_OBJECT_SORTING = builder.argument("skipObjectSorting", Boolean.class) .defaultValue(false) .description("When true will skip object sorting. This can be useful on databases that have a lot of packages/procedures that are " + @@ -56,7 +55,7 @@ protected static void validateReplaceIfExistsTypes(final CommandScope commandSco supportedReplaceIfExistsTypes.add("none"); replaceIfExistsTypes.removeAll(supportedReplaceIfExistsTypes); if (!replaceIfExistsTypes.isEmpty()) - throw new CommandValidationException("Invalid types for --replace-if-exists-types: " + replaceIfExistsTypes.stream().collect(Collectors.joining(", "))); + throw new CommandValidationException("Invalid types for --replace-if-exists-types: " + replaceIfExistsTypes.stream().collect(Collectors.joining(", ")) + ". Valid types are: " + REPLACE_IF_EXISTS_TYPES_NAMES.stream().collect(Collectors.joining(", "))); } protected static Stream supportedRunOnChangeTypes() { diff --git a/liquibase-standard/src/main/java/liquibase/util/StringUtil.java b/liquibase-standard/src/main/java/liquibase/util/StringUtil.java index 062718e8714..2f861ea58ed 100644 --- a/liquibase-standard/src/main/java/liquibase/util/StringUtil.java +++ b/liquibase-standard/src/main/java/liquibase/util/StringUtil.java @@ -790,11 +790,12 @@ public static String toKabobCase(String string) { return null; } - if (string.length() == 1) { + int length = string.length(); + if (length == 1) { return string; } - StringBuilder outString = new StringBuilder(); + StringBuilder outString = new StringBuilder(length); char[] charString = string.toCharArray(); for (int i = 0; i < charString.length; i++) { char letter = charString[i];