Class DGCClientSocket

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class DGCClientSocket
    extends Socket
    The DGCClientSocket simulates a connection to the DGC server side component of a remote object. All output that is written to the socket is dropped. When input is read from the socket, it returns a static DGC response that contains an invalid class (an Integer that violates the DGC deserialization filter). The standard behavior for the DGC is to give up on DGC calls when an invalid class is encountered. An alternative is to return a long living Lease. Currently where is only one use case in remote-method-guesser for this class that should create at maximum one DGC connection per remote endpoint. The implementation in this class is not suitable for connection reuse. If connections are reused, the DGC will encounter errors, since the static response always contains a full RMI handshake. In the current state this should never occur and even if it occurs, it shouldn't impact the user experience as DGC exceptions are handled hidden from the user. If reuse of connections is required in future, you may want to add a more sophisticated connection handling in this class, which checks whether a connection is newly created or being reused.
    Author:
    Tobias Neitzel (@qtc_de)
    • Constructor Detail

      • DGCClientSocket

        public DGCClientSocket​(String host,
                               int port)
        Create a new DGCClientSocket.
        Parameters:
        host - remote host
        port - remote port
    • Method Detail

      • getInputStream

        public InputStream getInputStream()
                                   throws IOException
        Simulates an InputStream that is connected to the DGC component of an RMI server. Always returns the same static response, which is the result of a DGC.dirty call. Instead of returning a Lease, we return an Integer, which triggers the deserialization filter of the DGC component and prevents remote references from being registered on the runtime.
        Overrides:
        getInputStream in class Socket
        Throws:
        IOException
      • getOutputStream

        public OutputStream getOutputStream()
        Simulate an OutputStream that is connected to the DGC component of an RMI server. Instead of sending data, the output stream drops anything that is put into it.
        Overrides:
        getOutputStream in class Socket