diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 734e68a0354df568f9ed5a647dc9566aa0223b83..5e41804c77409de7cfc2e527162bdfc3e6015bbc 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -151,9 +151,6 @@ sun/management/HotspotRuntimeMBean/GetSafepointSyncTime.java macosx-all # 6959636 javax/management/loading/LibraryLoader/LibraryLoaderTest.java windows-all -# 8005472 -com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.sh windows-all - ############################################################################ # jdk_math diff --git a/test/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java b/test/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java index ef6bff07f5f09aa493783e1850d02ef0c807d3b5..b5eb847fc551b177c7c61988abc7234903802370 100644 --- a/test/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java +++ b/test/com/sun/jmx/remote/NotificationMarshalVersions/Client/Client.java @@ -1,47 +1,78 @@ -import java.nio.charset.Charset; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchService; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import javax.management.MBeanServerConnection; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; +import javax.management.remote.JMXConnectionNotification; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public class Client { - public static void main(String[] argv) throws Exception { - if (argv.length != 1) throw new IllegalArgumentException("Expecting exactly one jmx url argument"); + public static void run(String url) throws Exception { + final int notifEmittedCnt = 10; + final CountDownLatch counter = new CountDownLatch(notifEmittedCnt); + final Set seqSet = Collections.synchronizedSet(new HashSet()); + final AtomicBoolean duplNotification = new AtomicBoolean(); - JMXServiceURL serverUrl = new JMXServiceURL(argv[0]); + JMXServiceURL serverUrl = new JMXServiceURL(url); ObjectName name = new ObjectName("test", "foo", "bar"); JMXConnector jmxConnector = JMXConnectorFactory.connect(serverUrl); System.out.println("client connected"); jmxConnector.addConnectionNotificationListener(new NotificationListener() { + @Override public void handleNotification(Notification notification, Object handback) { - System.err.println("no!" + notification); + System.out.println("connection notification: " + notification); + if (!seqSet.add(notification.getSequenceNumber())) { + duplNotification.set(true); + } + if (notification.getType().equals(JMXConnectionNotification.NOTIFS_LOST)) { + long lostNotifs = ((Long)((JMXConnectionNotification)notification).getUserData()).longValue(); + for(int i=0;i */ + static void compile(String... args) { + debug("Running: javac " + Arrays.toString(args)); + if (com.sun.tools.javac.Main.compile(args) != 0) { + throw new RuntimeException("javac failed: args=" + Arrays.toString(args)); + } + } +} diff --git a/test/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.sh b/test/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.sh deleted file mode 100644 index 1e69d979ed06c0fd02d186c426ada7f85e56a879..0000000000000000000000000000000000000000 --- a/test/com/sun/jmx/remote/NotificationMarshalVersions/TestSerializationMismatch.sh +++ /dev/null @@ -1,93 +0,0 @@ -# -# Copyright (c) 2005, 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 -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# @test -# @summary Tests for the RMI unmarshalling errors not to cause silent failure. -# @author Jaroslav Bachorik -# @bug 6937053 -# -# @run shell TestSerializationMismatch.sh -# - -#set -x - -#Set appropriate jdk -# - -if [ ! -z "${TESTJAVA}" ] ; then - jdk="$TESTJAVA" -else - echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." - exit 1 -fi - -SERVER_TESTCLASSES=$TESTCLASSES/Server -CLIENT_TESTCLASSES=$TESTCLASSES/Client - -URL_PATH=$SERVER_TESTCLASSES/jmxurl - -rm $URL_PATH - -mkdir -p $SERVER_TESTCLASSES -mkdir -p $CLIENT_TESTCLASSES - -$TESTJAVA/bin/javac -d $CLIENT_TESTCLASSES $TESTSRC/Client/ConfigKey.java $TESTSRC/Client/TestNotification.java $TESTSRC/Client/Client.java -$TESTJAVA/bin/javac -d $SERVER_TESTCLASSES $TESTSRC/Server/ConfigKey.java $TESTSRC/Server/TestNotification.java $TESTSRC/Server/SteMBean.java $TESTSRC/Server/Ste.java $TESTSRC/Server/Server.java - -startServer() -{ - ($TESTJAVA/bin/java -classpath $SERVER_TESTCLASSES Server) 1>$URL_PATH & - SERVER_PID=$! -} - -runClient() -{ - while true - do - [ -f $URL_PATH ] && break - sleep 2 - done - read JMXURL < $URL_PATH - - HAS_ERRORS=`($TESTJAVA/bin/java -classpath $CLIENT_TESTCLASSES Client $JMXURL) 2>&1 | grep -i "SEVERE: Failed to fetch notification, stopping thread. Error is: java.rmi.UnmarshalException"` -} - -startServer - -runClient - -sleep 1 # wait for notifications to arrive - -kill "$SERVER_PID" - -if [ -z "$HAS_ERRORS" ] -then - echo "Test PASSED" - exit 0 -fi - -echo "Test FAILED" -echo $HAS_ERRORS 1>&2 -exit 1 -