|
1 | 1 | /* |
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
74 | 74 | public final class MonitorVmStartTerminate { |
75 | 75 |
|
76 | 76 | private static final int PROCESS_COUNT = 10; |
| 77 | + private static final int ARGS_ATTEMPTS = 10; |
77 | 78 |
|
78 | 79 | public static void main(String... args) throws Exception { |
79 | 80 |
|
@@ -175,8 +176,6 @@ private void releaseTerminated(Integer id) { |
175 | 176 | } |
176 | 177 | } |
177 | 178 |
|
178 | | - private static final int ARGS_ATTEMPTS = 3; |
179 | | - |
180 | 179 | private boolean hasMainArgs(Integer id, String args) { |
181 | 180 | VmIdentifier vmid = null; |
182 | 181 | try { |
@@ -204,7 +203,10 @@ private boolean hasMainArgs(Integer id, String args) { |
204 | 203 | } catch (MonitorException e) { |
205 | 204 | // Process probably not running or not ours, e.g. |
206 | 205 | // 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 | + } |
208 | 210 | } |
209 | 211 | } |
210 | 212 | return false; |
@@ -249,23 +251,15 @@ private static void createFile(Path path) throws IOException { |
249 | 251 | } |
250 | 252 |
|
251 | 253 | 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); |
255 | 254 | long start = System.nanoTime(); |
| 255 | + System.out.println("Waiting for " + path + " to be removed"); |
256 | 256 | while (true) { |
257 | 257 | long now = System.nanoTime(); |
258 | 258 | long waited = now - start; |
259 | | - System.out.println("Waiting for " + path + " to be removed, " + waited + " ns"); |
260 | 259 | if (!Files.exists(path)) { |
| 260 | + System.out.println("waitForRemoval: " + path + " has been removed in " + waited + " ns"); |
261 | 261 | return; |
262 | 262 | } |
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 | | - } |
269 | 263 | takeNap(); |
270 | 264 | } |
271 | 265 | } |
|
0 commit comments