diff options
Diffstat (limited to 'src/share/classes/sun/rmi/transport/StreamRemoteCall.java')
-rw-r--r-- | src/share/classes/sun/rmi/transport/StreamRemoteCall.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/share/classes/sun/rmi/transport/StreamRemoteCall.java b/src/share/classes/sun/rmi/transport/StreamRemoteCall.java index d0a0ced040..cb71f7478a 100644 --- a/src/share/classes/sun/rmi/transport/StreamRemoteCall.java +++ b/src/share/classes/sun/rmi/transport/StreamRemoteCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2019, 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 @@ -36,6 +36,10 @@ import java.rmi.MarshalException; import java.rmi.UnmarshalException; import java.rmi.server.ObjID; import java.rmi.server.RemoteCall; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import sun.misc.ObjectInputFilter; import sun.rmi.runtime.Log; import sun.rmi.server.UnicastRef; import sun.rmi.transport.tcp.TCPEndpoint; @@ -50,6 +54,7 @@ public class StreamRemoteCall implements RemoteCall { private ConnectionInputStream in = null; private ConnectionOutputStream out = null; private Connection conn; + private ObjectInputFilter filter = null; private boolean resultStarted = false; private Exception serverException = null; @@ -123,6 +128,13 @@ public class StreamRemoteCall implements RemoteCall { } } + 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. @@ -132,6 +144,12 @@ public class StreamRemoteCall implements RemoteCall { Transport.transportLog.log(Log.VERBOSE, "getting input stream"); in = new ConnectionInputStream(conn.getInputStream()); + if (filter != null) { + AccessController.doPrivileged((PrivilegedAction<Void>) () -> { + ObjectInputFilter.Config.setObjectInputFilter(in, filter); + return null; + }); + } } return in; } @@ -251,6 +269,7 @@ public class StreamRemoteCall implements RemoteCall { try { ex = in.readObject(); } catch (Exception e) { + discardPendingRefs(); throw new UnmarshalException("Error unmarshaling return", e); } @@ -259,6 +278,7 @@ public class StreamRemoteCall implements RemoteCall { if (ex instanceof Exception) { exceptionReceivedFromServer((Exception) ex); } else { + discardPendingRefs(); throw new UnmarshalException("Return type not Exception"); } // Exception is thrown before fallthrough can occur |