java.rmi.ConnectIOException Java Examples
The following examples show how to use
java.rmi.ConnectIOException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RMIRegistryExploit.java From ysoserial with MIT License | 6 votes |
public static void main(final String[] args) throws Exception { final String host = args[0]; final int port = Integer.parseInt(args[1]); final String command = args[3]; Registry registry = LocateRegistry.getRegistry(host, port); final String className = CommonsCollections1.class.getPackage().getName() + "." + args[2]; final Class<? extends ObjectPayload> payloadClass = (Class<? extends ObjectPayload>) Class.forName(className); // test RMI registry connection and upgrade to SSL connection on fail try { registry.list(); } catch(ConnectIOException ex) { registry = LocateRegistry.getRegistry(host, port, new RMISSLClientSocketFactory()); } // ensure payload doesn't detonate during construction or deserialization exploit(registry, payloadClass, command); }
Example #2
Source File: TCPChannel.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #3
Source File: TCPChannel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #4
Source File: TCPChannel.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #5
Source File: TCPChannel.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #6
Source File: TCPChannel.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #7
Source File: TCPChannel.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #8
Source File: TCPChannel.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #9
Source File: TCPChannel.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #10
Source File: TCPChannel.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #11
Source File: TCPChannel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #12
Source File: TCPChannel.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #13
Source File: TCPChannel.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #14
Source File: TCPChannel.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Send transport header over stream. */ private void writeTransportHeader(DataOutputStream out) throws RemoteException { try { // write out transport header DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeInt(TransportConstants.Magic); dataOut.writeShort(TransportConstants.Version); } catch (IOException e) { throw new ConnectIOException( "error writing JRMP transport header", e); } }
Example #15
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithConnectIOExceptionAndRefresh() throws Exception { doTestRmiProxyFactoryBeanWithExceptionAndRefresh(ConnectIOException.class); }
Example #16
Source File: HandshakeFailure.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(0); int port = serverSocket.getLocalPort(); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(port); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { throw new RuntimeException( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #17
Source File: HandshakeFailure.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #18
Source File: HandshakeTimeout.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #19
Source File: HandshakeFailure.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #20
Source File: HandshakeTimeout.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #21
Source File: HandshakeTimeout.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #22
Source File: HandshakeFailure.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #23
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithConnectIOException() throws Exception { doTestRmiProxyFactoryBeanWithException(ConnectIOException.class); }
Example #24
Source File: HandshakeFailure.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #25
Source File: HandshakeFailure.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #26
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithBusinessInterfaceAndConnectIOException() throws Exception { doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException( ConnectIOException.class, RemoteConnectFailureException.class); }
Example #27
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithBusinessInterfaceAndConnectIOExceptionAndRefresh() throws Exception { doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh( ConnectIOException.class, RemoteConnectFailureException.class); }
Example #28
Source File: HandshakeTimeout.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #29
Source File: HandshakeTimeout.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #30
Source File: HandshakeFailure.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }