Skip to content

Commit

Permalink
8274621: NullPointerException because listenAddress[0] is null
Browse files Browse the repository at this point in the history
Backport-of: 5bbc8d3cb2ce487b367ee1a621d78699c9b30100
  • Loading branch information
Andrew Lu committed Jan 10, 2024
1 parent c360cd5 commit 8a1e29d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/lib/jdk/test/lib/process/ProcessTools.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -113,12 +113,12 @@ public static Process startProcess(String name,
* <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.
Expand All @@ -143,14 +143,14 @@ public static Process startProcess(String name,
* <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.
Expand Down Expand Up @@ -190,10 +190,14 @@ protected void processLine(String line) {
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();
}
}
}
};
Expand Down Expand Up @@ -238,13 +242,13 @@ protected void processLine(String line) {
* <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.
Expand Down

1 comment on commit 8a1e29d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.