Skip to content

Commit 841989b

Browse files
committed
8318730: MonitorVmStartTerminate.java still times out after JDK-8209595
Reviewed-by: lmesnik, sspitsyn, cjplummer
1 parent 44374a5 commit 841989b

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

test/jdk/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -74,6 +74,7 @@
7474
public final class MonitorVmStartTerminate {
7575

7676
private static final int PROCESS_COUNT = 10;
77+
private static final int ARGS_ATTEMPTS = 10;
7778

7879
public static void main(String... args) throws Exception {
7980

@@ -175,8 +176,6 @@ private void releaseTerminated(Integer id) {
175176
}
176177
}
177178

178-
private static final int ARGS_ATTEMPTS = 3;
179-
180179
private boolean hasMainArgs(Integer id, String args) {
181180
VmIdentifier vmid = null;
182181
try {
@@ -204,7 +203,10 @@ private boolean hasMainArgs(Integer id, String args) {
204203
} catch (MonitorException e) {
205204
// Process probably not running or not ours, e.g.
206205
// sun.jvmstat.monitor.MonitorException: Could not attach to PID
207-
System.out.println("hasMainArgs(" + id + "): " + e);
206+
// Only log if something else, to avoid filling log:
207+
if (!e.getMessage().contains("Could not attach")) {
208+
System.out.println("hasMainArgs(" + id + "): " + e);
209+
}
208210
}
209211
}
210212
return false;
@@ -249,23 +251,15 @@ private static void createFile(Path path) throws IOException {
249251
}
250252

251253
private static void waitForRemoval(Path path) {
252-
String timeoutFactorText = System.getProperty("test.timeout.factor", "1.0");
253-
double timeoutFactor = Double.parseDouble(timeoutFactorText);
254-
long timeoutNanos = 1000_000_000L*(long)(1000*timeoutFactor);
255254
long start = System.nanoTime();
255+
System.out.println("Waiting for " + path + " to be removed");
256256
while (true) {
257257
long now = System.nanoTime();
258258
long waited = now - start;
259-
System.out.println("Waiting for " + path + " to be removed, " + waited + " ns");
260259
if (!Files.exists(path)) {
260+
System.out.println("waitForRemoval: " + path + " has been removed in " + waited + " ns");
261261
return;
262262
}
263-
if (waited > timeoutNanos) {
264-
System.out.println("Start: " + start);
265-
System.out.println("Now: " + now);
266-
System.out.println("Process timed out after " + waited + " ns. Abort.");
267-
System.exit(1);
268-
}
269263
takeNap();
270264
}
271265
}

0 commit comments

Comments
 (0)