gnodet commented on code in PR #881: URL: https://github.com/apache/maven-mvnd/pull/881#discussion_r1338286106
########## client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java: ########## @@ -69,6 +73,11 @@ public class DaemonConnector { private static final Logger LOGGER = LoggerFactory.getLogger(DaemonConnector.class); + private static final Function<DaemonInfo, Boolean> daemonIsIdle = di -> di.getState() == DaemonState.Idle; Review Comment: Why not using method if we don't want to inline those methods ? ########## client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java: ########## @@ -391,30 +412,21 @@ private Process startDaemonProcess(String daemonId, ClientOutput output) { host = "localhost"; port = address; } - if (!port.matches("[0-9]+")) { + if (!port.matches("\\d+")) { throw new IllegalArgumentException("Wrong debug address syntax: " + address); } int iPort = Integer.parseInt(port); if (iPort == 0) { - try (ServerSocketChannel channel = SocketFamily.inet.openServerSocket()) { - iPort = ((InetSocketAddress) channel.getLocalAddress()).getPort(); - } catch (IOException e) { - throw new IllegalStateException("Unable to find a free debug port", e); - } + iPort = findPort(); } + address = host + ":" + iPort; output.accept(Message.buildStatus("Daemon listening for debugger on address: " + address)); args.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=" + address); } // jvm args - String jvmArgs = parameters.jvmArgs(); - if (jvmArgs != null) { - for (String arg : jvmArgs.split(" ")) { - if (!arg.isEmpty()) { - args.add(arg); - } - } - } + String jvmArgs = Objects.toString(parameters.jvmArgs(), ""); + args.addAll(Stream.of(jvmArgs.split(" ")).filter(nonEmpty).collect(Collectors.toList())); Review Comment: `Stream.of(jvmArgs.split(" ")).filter(nonEmpty).forEach(args::add)` ? to avoid the `toList` step ########## client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java: ########## @@ -194,6 +203,7 @@ private String handleStopEvents( .collect(Collectors.groupingBy(DaemonStopEvent::getDaemonId, Collectors.minBy(this::compare))) .values() .stream() + .filter(Optional::isPresent) Review Comment: I know IntelliJ prints a warning `'Optional::get' without 'isPresent()' check`, but I think this is not a possible case : the `groupingBy` would not create a key if there's no value, so `minBy` will always return a non empty Optional. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org