changeset 53476:ffb3065f13fe jdk-12.0.2+9

8227230: Backout JDK-8215367 from update releases Reviewed-by: smarks, bpb, lancea
author igerasim
date Wed, 03 Jul 2019 18:55:46 -0700
parents 9c7722912621
children 7b6accc7c009
files src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java test/jdk/java/rmi/testlibrary/TestSocketFactory.java
diffstat 3 files changed, 25 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java	Tue Jul 16 16:38:19 2019 +0000
+++ b/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl_Stub.java	Wed Jul 03 18:55:46 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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
@@ -25,16 +25,16 @@
 
 package sun.rmi.transport;
 
-import sun.rmi.transport.tcp.TCPConnection;
-
 import java.io.ObjectInputFilter;
-import java.rmi.RemoteException;
+import java.io.ObjectInputStream;
 import java.rmi.dgc.Lease;
 import java.rmi.dgc.VMID;
 import java.rmi.server.UID;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.ArrayList;
+
+import sun.rmi.server.UnicastRef;
+import sun.rmi.transport.tcp.TCPConnection;
 
 /**
  * Stubs to invoke DGC remote methods.
@@ -72,12 +72,7 @@
     public void clean(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.VMID $param_VMID_3, boolean $param_boolean_4)
             throws java.rmi.RemoteException {
         try {
-            StreamRemoteCall call = (StreamRemoteCall)ref.newCall((java.rmi.server.RemoteObject) this,
-                    operations, 0, interfaceHash);
-            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-                call.setObjectInputFilter(DGCImpl_Stub::leaseFilter);
-                return null;
-            });
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
             try {
                 java.io.ObjectOutput out = call.getOutputStream();
                 out.writeObject($param_arrayOf_ObjID_1);
@@ -102,13 +97,7 @@
     public java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[] $param_arrayOf_ObjID_1, long $param_long_2, java.rmi.dgc.Lease $param_Lease_3)
             throws java.rmi.RemoteException {
         try {
-            StreamRemoteCall call =
-                    (StreamRemoteCall)ref.newCall((java.rmi.server.RemoteObject) this,
-                            operations, 1, interfaceHash);
-            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-                call.setObjectInputFilter(DGCImpl_Stub::leaseFilter);
-                return null;
-            });
+            java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
             try {
                 java.io.ObjectOutput out = call.getOutputStream();
                 out.writeObject($param_arrayOf_ObjID_1);
@@ -119,9 +108,20 @@
             }
             ref.invoke(call);
             java.rmi.dgc.Lease $result;
-            Connection connection = call.getConnection();
+            Connection connection = ((StreamRemoteCall) call).getConnection();
             try {
                 java.io.ObjectInput in = call.getInputStream();
+
+                if (in instanceof ObjectInputStream) {
+                    /**
+                     * Set a filter on the stream for the return value.
+                     */
+                    ObjectInputStream ois = (ObjectInputStream) in;
+                    AccessController.doPrivileged((PrivilegedAction<Void>)() -> {
+                        ois.setObjectInputFilter(DGCImpl_Stub::leaseFilter);
+                        return null;
+                    });
+                }
                 $result = (java.rmi.dgc.Lease) in.readObject();
             } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
                 if (connection instanceof TCPConnection) {
@@ -146,11 +146,6 @@
      * ObjectInputFilter to filter DGCClient return value (a Lease).
      * The list of acceptable classes is very short and explicit.
      * The depth and array sizes are limited.
-     * <p>
-     * The filter must accept normal and exception returns.
-     * A DGC server may throw exceptions that may have a cause
-     * and suppressed exceptions.
-     * Only exceptions in {@code java.base} and {@code java.rmi} are allowed.
      *
      * @param filterInfo access to class, arrayLength, etc.
      * @return  {@link ObjectInputFilter.Status#ALLOWED} if allowed,
@@ -177,14 +172,7 @@
             }
             return (clazz == UID.class ||
                     clazz == VMID.class ||
-                    clazz == Lease.class ||
-                    (Throwable.class.isAssignableFrom(clazz) &&
-                            (Object.class.getModule() == clazz.getModule() ||
-                                    RemoteException.class.getModule() == clazz.getModule())) ||
-                    clazz == StackTraceElement.class ||
-                    clazz == ArrayList.class ||     // for suppressed exceptions, if any
-                    clazz == Object.class ||
-                    clazz.getName().equals("java.util.Collections$EmptyList"))
+                    clazz == Lease.class)
                     ? ObjectInputFilter.Status.ALLOWED
                     : ObjectInputFilter.Status.REJECTED;
         }
--- a/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java	Tue Jul 16 16:38:19 2019 +0000
+++ b/src/java.rmi/share/classes/sun/rmi/transport/StreamRemoteCall.java	Wed Jul 03 18:55:46 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -29,7 +29,6 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.ObjectInput;
-import java.io.ObjectInputFilter;
 import java.io.ObjectOutput;
 import java.io.StreamCorruptedException;
 import java.rmi.RemoteException;
@@ -51,7 +50,6 @@
     private ConnectionInputStream in = null;
     private ConnectionOutputStream out = null;
     private Connection conn;
-    private ObjectInputFilter filter = null;
     private boolean resultStarted = false;
     private Exception serverException = null;
 
@@ -125,13 +123,6 @@
         }
     }
 
-    public void setObjectInputFilter(ObjectInputFilter filter) {
-        if (in != null) {
-            throw new IllegalStateException("set filter must occur before calling getInputStream");
-        }
-        this.filter = filter;
-    }
-
     /**
      * Get the InputStream the stub/skeleton should get results/arguments
      * from.
@@ -141,9 +132,6 @@
             Transport.transportLog.log(Log.VERBOSE, "getting input stream");
 
             in = new ConnectionInputStream(conn.getInputStream());
-            if (filter != null) {
-                in.setObjectInputFilter(filter);
-            }
         }
         return in;
     }
--- a/test/jdk/java/rmi/testlibrary/TestSocketFactory.java	Tue Jul 16 16:38:19 2019 +0000
+++ b/test/jdk/java/rmi/testlibrary/TestSocketFactory.java	Wed Jul 03 18:55:46 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, 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
@@ -92,8 +92,7 @@
 
     static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
 
-    // True to enable logging of matches and replacements.
-    private static volatile boolean debugLogging = false;
+    public static final boolean DEBUG = false;
 
     /**
      * Debugging output can be synchronized with logging of RMI actions.
@@ -101,8 +100,8 @@
      * @param format a printf format
      * @param args   any args
      */
-    public static void DEBUG(String format, Object... args) {
-        if (debugLogging) {
+    private static void DEBUG(String format, Object... args) {
+        if (DEBUG) {
             System.err.printf(format, args);
         }
     }
@@ -118,17 +117,6 @@
     }
 
     /**
-     * Set debug to true to generate logging output of matches and substitutions.
-     * @param debug {@code true} to generate logging output
-     * @return the previous value
-     */
-    public static boolean setDebug(boolean debug) {
-        boolean oldDebug = debug;
-        debugLogging = debug;
-        return oldDebug;
-    }
-
-    /**
      * Set the match and replacement bytes, with an empty trigger.
      * The match and replacements are propagated to all existing sockets.
      *