changeset 1763:0765375af7d0

8186998: Improve JMX supportive features Summary: Improve JMX supportive features Reviewed-by: mchung, dfuchs, rriggs, hb, skoivu, rhalade
author uvangapally
date Mon, 25 Sep 2017 19:44:28 +0530
parents 98682486eca1
children e63c5790ed31
files src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java test/javax/management/remote/nonLocalAccess/NonLocalJMXRemoteTest.java
diffstat 2 files changed, 46 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Fri Sep 22 12:09:34 2017 -0700
+++ b/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Mon Sep 25 19:44:28 2017 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, 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
@@ -43,7 +43,12 @@
 public class SingleEntryRegistry extends RegistryImpl {
     SingleEntryRegistry(int port, String name, Remote object)
             throws RemoteException {
-        super(port);
+        super(port, null, null, new ObjectInputFilter() {
+            @Override
+            public Status checkInput(FilterInfo info) {
+                return SingleEntryRegistry.singleRegistryFilter(info);
+            }
+        });
         this.name = name;
         this.object = object;
     }
@@ -54,7 +59,12 @@
                         String name,
                         Remote object)
             throws RemoteException {
-        super(port, csf, ssf, singleRegistryFilter());
+        super(port, csf, ssf, new ObjectInputFilter() {
+            @Override
+            public Status checkInput(FilterInfo info) {
+                return SingleEntryRegistry.singleRegistryFilter(info);
+            }
+        });
         this.name = name;
         this.object = object;
     }
@@ -90,18 +100,13 @@
      * @param info a reference to the serialization filter information
      * @return Status.REJECTED if parameters are out of range
      */
-    private static ObjectInputFilter singleRegistryFilter() {
-        return new ObjectInputFilter() {
-            @Override
-            public Status checkInput(FilterInfo info) {
-                return (info.serialClass() != null ||
-                        info.depth() > 2 ||
-                        info.references() > 4 ||
-                        info.arrayLength() >= 0)
-                        ? ObjectInputFilter.Status.REJECTED
-                        : ObjectInputFilter.Status.ALLOWED;
-            }
-        };
+    private static ObjectInputFilter.Status singleRegistryFilter(ObjectInputFilter.FilterInfo info) {
+        return (info.serialClass() != null ||
+                info.depth() > 2 ||
+                info.references() > 4 ||
+                info.arrayLength() >= 0)
+                ? ObjectInputFilter.Status.REJECTED
+                : ObjectInputFilter.Status.ALLOWED;
     }
 
     private final String name;
--- a/test/javax/management/remote/nonLocalAccess/NonLocalJMXRemoteTest.java	Fri Sep 22 12:09:34 2017 -0700
+++ b/test/javax/management/remote/nonLocalAccess/NonLocalJMXRemoteTest.java	Mon Sep 25 19:44:28 2017 +0530
@@ -44,14 +44,37 @@
  * This tests the SingleEntryRegistry implemented by JMX.
  * This test is a manual test and uses JMX running on a *different* host.
  * JMX can be enabled in any Java runtime; for example:
- * login or ssh to the different host and invoke rmiregistry with arguments below.
+ *
+ * Note: Use remote host with latest JDK update release for invoking rmiregistry.
+ *
+ * Note: Test should be ran twice once using arg1 and once using arg2.
+ *
+ * login or ssh to the remote host and invoke rmiregistry with arg1.
  * It will not show any output.
- * {@code $JDK_HOME/bin/rmiregistry \
+ * Execute the test, after test completes execution, stop the server.
+ *
+ * repeat above step using arg2 and execute the test.
+ *
+ *
+ * arg1: {@code $JDK_HOME/bin/rmiregistry \
  *         -J-Dcom.sun.management.jmxremote.port=8888 \
  *         -J-Dcom.sun.management.jmxremote.local.only=false \
  *         -J-Dcom.sun.management.jmxremote.ssl=false \
  *         -J-Dcom.sun.management.jmxremote.authenticate=false
  * }
+ *
+ *
+ * replace "jmx-registry-host" with the hostname or IP address of the remote host
+ * for property "-J-Dcom.sun.management.jmxremote.host" below.
+ *
+ * arg2: {@code $JDK_HOME/bin/rmiregistry \
+ *         -J-Dcom.sun.management.jmxremote.port=8888 \
+ *         -J-Dcom.sun.management.jmxremote.local.only=false \
+ *         -J-Dcom.sun.management.jmxremote.ssl=false \
+ *         -J-Dcom.sun.management.jmxremote.authenticate=false \
+ *         -J-Dcom.sun.management.jmxremote.host="jmx-registry-host"
+ * }
+ *
  * On the first host modify the @run command above to replace "jmx-registry-host"
  * with the hostname or IP address of the different host and run the test with jtreg.
  */
@@ -133,6 +156,7 @@
             if (asIndex < 0 ||
                     disallowIndex < 0 ||
                     nonLocalHostIndex < 0 ) {
+                System.out.println("Exception message is " + msg);
                 throw new RuntimeException("exception message is malformed", t);
             }
             System.out.printf("Found expected AccessException: %s%n%n", t);