Skip to content

Commit

Permalink
Move unknown options check further in the startup (hyperledger#7066)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored and matthew1001 committed Jun 7, 2024
1 parent df3e25e commit 4d74a97
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class TomlConfigurationDefaultProvider implements IDefaultValueProvider {
private final CommandLine commandLine;
private final InputStream configurationInputStream;
private TomlParseResult result;
private boolean isUnknownOptionsChecked;

/**
* Instantiates a new Toml config file default value provider.
Expand Down Expand Up @@ -230,6 +231,11 @@ private void checkConfigurationValidity() {
throw new ParameterException(
commandLine,
String.format("Unable to read TOML configuration file %s", configurationInputStream));

if (!isUnknownOptionsChecked && !commandLine.isUnmatchedArgumentsAllowed()) {
checkUnknownOptions(result);
isUnknownOptionsChecked = true;
}
}

/** Load configuration from file. */
Expand All @@ -249,8 +255,6 @@ public void loadConfigurationFromFile() {
commandLine, String.format("Invalid TOML configuration: %s", errors));
}

checkUnknownOptions(result);

this.result = result;

} catch (final IOException e) {
Expand Down

0 comments on commit 4d74a97

Please sign in to comment.