8274621: NullPointerException because listenAddress[0] is null

Reviewed-by: sspitsyn, lmesnik, cjplummer
This commit is contained in:
Alex Menkov 2021-10-29 21:38:24 +00:00
parent 5021a12cea
commit 5bbc8d3cb2

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -116,12 +116,12 @@ public final class ProcessTools {
* <span>The default redirects of STDOUT and STDERR are started</span>
* <p>
* It is possible to wait for the process to get to a warmed-up state
* via {@linkplain Predicate} condition on the STDOUT
* via {@linkplain Predicate} condition on the STDOUT/STDERR
* </p>
*
* @param name The process name
* @param processBuilder The process builder
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT and STDERR.
* Used to determine the moment the target app is
* properly warmed-up.
* It can be null - in that case the warmup is skipped.
@ -146,14 +146,14 @@ public final class ProcessTools {
* <span>The default redirects of STDOUT and STDERR are started</span>
* <p>
* It is possible to wait for the process to get to a warmed-up state
* via {@linkplain Predicate} condition on the STDOUT and monitor the
* via {@linkplain Predicate} condition on the STDOUT/STDERR and monitor the
* in-streams via the provided {@linkplain Consumer}
* </p>
*
* @param name The process name
* @param processBuilder The process builder
* @param lineConsumer The {@linkplain Consumer} the lines will be forwarded to
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT and STDERR.
* Used to determine the moment the target app is
* properly warmed-up.
* It can be null - in that case the warmup is skipped.
@ -193,10 +193,14 @@ public final class ProcessTools {
CountDownLatch latch = new CountDownLatch(1);
if (linePredicate != null) {
StreamPumper.LinePump pump = new StreamPumper.LinePump() {
// synchronization between stdout and stderr pumps
private final Object sync = new Object();
@Override
protected void processLine(String line) {
if (latch.getCount() > 0 && linePredicate.test(line)) {
latch.countDown();
synchronized (sync) {
if (latch.getCount() > 0 && linePredicate.test(line)) {
latch.countDown();
}
}
}
};
@ -241,13 +245,13 @@ public final class ProcessTools {
* <span>The default redirects of STDOUT and STDERR are started</span>
* <p>
* It is possible to wait for the process to get to a warmed-up state
* via {@linkplain Predicate} condition on the STDOUT. The warm-up will
* wait indefinitely.
* via {@linkplain Predicate} condition on the STDOUT/STDERR.
* The warm-up will wait indefinitely.
* </p>
*
* @param name The process name
* @param processBuilder The process builder
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT
* @param linePredicate The {@linkplain Predicate} to use on the STDOUT and STDERR.
* Used to determine the moment the target app is
* properly warmed-up.
* It can be null - in that case the warmup is skipped.