7140929: NotSerializableNotifTest.java fails intermittently
Reviewed-by: sjiang, alanb
--- a/jdk/test/javax/management/remote/mandatory/notif/NotSerializableNotifTest.java Mon Oct 21 12:00:58 2013 +0200
+++ b/jdk/test/javax/management/remote/mandatory/notif/NotSerializableNotifTest.java Mon Oct 21 13:57:11 2013 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013, 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
@@ -33,8 +33,8 @@
// java imports
//
-import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.Map;
// JMX imports
//
@@ -44,7 +44,7 @@
import javax.management.remote.JMXServiceURL;
public class NotSerializableNotifTest {
- private static MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
+ private static final MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
private static ObjectName emitter;
private static int port = 2468;
@@ -52,9 +52,19 @@
private static final int sentNotifs = 10;
+ private static double timeoutFactor = 1.0;
+ private static final double defaultTimeout = 10;
+
public static void main(String[] args) throws Exception {
System.out.println(">>> Test to send a not serializable notification");
+ String timeoutVal = System.getProperty("test.timeout.factor");
+ if (timeoutVal != null) {
+ timeoutFactor = Double.parseDouble(
+ System.getProperty("test.timeout.factor")
+ );
+ }
+
// IIOP fails on JDK1.4, see 5034318
final String v = System.getProperty("java.version");
float f = Float.parseFloat(v.substring(0, 3));
@@ -136,7 +146,8 @@
// waiting ...
synchronized (listener) {
- for (int i=0; i<10; i++) {
+ int top = (int)Math.ceil(timeoutFactor * defaultTimeout);
+ for (int i=0; i<top; i++) {
if (listener.received() < sentNotifs) {
listener.wait(1000);
} else {