Skip to content

Commit

Permalink
Refactor dry-run code in StartDomainCommand
Browse files Browse the repository at this point in the history
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
  • Loading branch information
OndroMih committed Jun 19, 2023
1 parent 4c14a7a commit 9f7123f
Showing 1 changed file with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
import static java.util.logging.Level.FINER;
import static org.glassfish.api.admin.RuntimeType.DAS;

import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
* The start-domain command.
*
Expand Down Expand Up @@ -142,23 +145,15 @@ protected int executeCommand() throws CommandException {
if (dry_run) {
logger.fine(Strings.get("dry_run_msg"));
List<String> cmd = glassFishLauncher.getCommandLine();
StringBuilder sb = new StringBuilder();
boolean skipLine = false;
for (String s : cmd) {
if (s.equals("-read-stdin")) {
// Don't print this option as it's not needed to run the server
int indexOfReadStdin = cmd.indexOf("-read-stdin");
String cmdToLog = IntStream.range(0, cmd.size())
// Don't print -read-stdin option as it's not needed to run the server
// Also skip the next line with "true", which is related to this option
skipLine = true;
continue;
}
if (skipLine) {
skipLine = false;
continue;
}
sb.append(s);
sb.append('\n');
}
logger.info(sb.toString());
.filter(index -> index < indexOfReadStdin || index > indexOfReadStdin + 1)
.mapToObj(cmd::get)
.collect(Collectors.joining("\n"))
+ "\n";
logger.info(cmdToLog);
return SUCCESS;
}

Expand Down

0 comments on commit 9f7123f

Please sign in to comment.