Java 类java.rmi.ConnectIOException 实例源码

项目:incubator-taverna-server    文件:ForkRunFactory.java   
@Override
protected RemoteSingleRun getRealRun(UsernamePrincipal creator,
        Workflow workflow, UUID id) throws Exception {
    @Nonnull
    byte[] wf = serializeWorkflow(workflow);
    for (int i = 0; i < 3; i++) {
        initFactory();
        try {
            return getRealRun(creator, wf, id);
        } catch (ConnectException | ConnectIOException e) {
            // factory was lost; try to recreate
        }
        killFactory();
    }
    throw new NoCreateException("total failure to connect to factory "
            + factoryProcessName + "despite attempting restart");
}
项目:incubator-taverna-server    文件:IdAwareForkRunFactory.java   
@Override
protected RemoteSingleRun getRealRun(UsernamePrincipal creator,
        Workflow workflow, UUID id) throws Exception {
    byte[] wf = serializeWorkflow(workflow);
    String username = mapper == null ? null : mapper
            .getUsernameForPrincipal(creator);
    if (username == null)
        throw new Exception("cannot determine who to run workflow as; "
                + "local identity mapper returned null");
    for (int i = 0; i < 3; i++) {
        if (!factory.containsKey(username))
            initFactory(username);
        try {
            return getRealRun(creator, username, wf, id);
        } catch (ConnectException | ConnectIOException e) {
            // factory was lost; try to recreate
        }
        factory.remove(username);
    }
    throw new NoCreateException("total failure to connect to factory "
            + factoryProcessName + "despite attempting restart");
}
项目:JRemoting    文件:RmiTransport.java   
public RmiTransport(ClientMonitor clientMonitor, ScheduledExecutorService executorService, ConnectionPinger connectionPinger, SocketDetails addr) throws ConnectionException {

        super(clientMonitor, executorService, connectionPinger, RmiTransport.class.getClassLoader());

        url = "rmi://" + addr.getHostName() + ":" + addr.getPort() + "/" + RmiInvoker.class.getName();

        try {
            rmiInvoker = (RmiInvoker) Naming.lookup(url);
        } catch (NotBoundException nbe) {
            throw new ConnectionException("Cannot bind to the remote RMI service.  Either an IP or RMI issue.");
        } catch (MalformedURLException mfue) {
            throw new ConnectionException("Malformed URL, host/port (" + addr.getHostName() + "/" + addr.getPort() + ") must be wrong: " + mfue.getMessage());
        } catch (ConnectIOException cioe) {
            throw new ConnectionException("Cannot connect to remote RMI server. " + "It is possible that transport mismatch", cioe);
        } catch (RemoteException re) {
            throw new ConnectionException("Unknown Remote Exception : " + re.getMessage());
        }
    }
项目:cn1    文件:ClientConnection.java   
/**
 * Writes RMI protocol header and RMI protocol version to the open
 * OutputStream.
 *
 * @param dout DataOutputStream to write header to
 *
 * @throws RemoteException if any I/O error occurred while writing header
 */
protected void writeHeader(DataOutputStream dout) throws RemoteException {
    try {
        dout.writeInt(RMI_HEADER);
        dout.writeShort(PROTOCOL_VER);
    } catch (IOException ioe) {
        // rmi.41=Unable to write RMI protocol header
        throw new ConnectIOException(Messages.getString("rmi.41"), ioe); //$NON-NLS-1$
    }

    if (transportLog.isLoggable(RMILog.VERBOSE)) {
        // rmi.log.94=Using protocol version {0}
        transportLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.94", //$NON-NLS-1$
                PROTOCOL_VER));
    }
}
项目:cn1    文件:Endpoint.java   
/**
 * Creates and returns socket.
 *
 * @return created socket
 */
public Socket createSocket() throws RemoteException {
    Socket s;

    try {
        s = DefaultRMISocketFactory.getNonNullClientFactory(csf)
                .createSocket(host, port);
    } catch (java.net.UnknownHostException uhe) {
        // rmi.80=Unable to connect to server {0}
        throw new java.rmi.UnknownHostException(
                Messages.getString("rmi.80", toString()), uhe); //$NON-NLS-1$
    } catch (java.net.ConnectException ce) {
        throw new java.rmi.ConnectException(
                Messages.getString("rmi.80", toString()), ce); //$NON-NLS-1$
    } catch (IOException ioe) {
        throw new ConnectIOException(
                Messages.getString("rmi.80", toString()), ioe); //$NON-NLS-1$
    }
    return s;
}
项目:freeVM    文件:AbstractClientConnection.java   
/**
 * Creates a new connection to the specified
 * {@link org.apache.harmony.rmi.internal.transport.Endpoint} using the underlying
 * {@link java.net.Socket}
 * 
 * @param sock
 *            the {@link java.net.Socket} to which the connection belongs
 * @param ep
 *            the {@link org.apache.harmony.rmi.internal.transport.Endpoint} for this
 *            connection
 * @throws ConnectIOException
 *             if an IOException occurs while making a connection to the
 *             remote host
 */
public AbstractClientConnection(Socket sock, Endpoint ep)
        throws ConnectIOException {
    this.ep = ep;
    this.lastUsageTime = null;
    clientConnectionID = ++clientConnectionCounter;
    this.sock = sock;
    try {
        this.out = new DataOutputStream(new BufferedOutputStream(sock
                .getOutputStream()));
        this.in = new DataInputStream(new BufferedInputStream(sock
                .getInputStream()));
    } catch (IOException e) {
        throw new ConnectIOException("I/O exception Creating Connection", e);
    }
    protocolHandler = new ClientProtocolHandler(this.in, this.out);
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:freeVM    文件:AbstractClientConnection.java   
/**
 * Creates a new connection to the specified
 * {@link ar.org.fitc.rmi.transport.Endpoint} using the underlying
 * {@link java.net.Socket}
 * 
 * @param sock
 *            the {@link java.net.Socket} to which the connection belongs
 * @param ep
 *            the {@link ar.org.fitc.rmi.transport.Endpoint} for this
 *            connection
 * @throws ConnectIOException
 *             if an IOException occurs while making a connection to the
 *             remote host
 */
public AbstractClientConnection(Socket sock, Endpoint ep)
        throws ConnectIOException {
    this.ep = ep;
    this.lastUsageTime = null;
    clientConnectionID = ++clientConnectionCounter;
    this.sock = sock;
    try {
        this.out = new DataOutputStream(new BufferedOutputStream(sock
                .getOutputStream()));
        this.in = new DataInputStream(new BufferedInputStream(sock
                .getInputStream()));
    } catch (IOException e) {
        throw new ConnectIOException("I/O exception Creating Connection", e);
    }
    protocolHandler = new ClientProtocolHandler(this.in, this.out);
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:freeVM    文件:ClientConnection.java   
/**
 * Writes RMI protocol header and RMI protocol version to the open
 * OutputStream.
 *
 * @param dout DataOutputStream to write header to
 *
 * @throws RemoteException if any I/O error occurred while writing header
 */
protected void writeHeader(DataOutputStream dout) throws RemoteException {
    try {
        dout.writeInt(RMI_HEADER);
        dout.writeShort(PROTOCOL_VER);
    } catch (IOException ioe) {
        // rmi.41=Unable to write RMI protocol header
        throw new ConnectIOException(Messages.getString("rmi.41"), ioe); //$NON-NLS-1$
    }

    if (transportLog.isLoggable(RMILog.VERBOSE)) {
        // rmi.log.94=Using protocol version {0}
        transportLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.94", //$NON-NLS-1$
                PROTOCOL_VER));
    }
}
项目:freeVM    文件:Endpoint.java   
/**
 * Creates and returns socket.
 *
 * @return created socket
 */
public Socket createSocket() throws RemoteException {
    Socket s;

    try {
        s = DefaultRMISocketFactory.getNonNullClientFactory(csf)
                .createSocket(host, port);
    } catch (java.net.UnknownHostException uhe) {
        // rmi.80=Unable to connect to server {0}
        throw new java.rmi.UnknownHostException(
                Messages.getString("rmi.80", toString()), uhe); //$NON-NLS-1$
    } catch (java.net.ConnectException ce) {
        throw new java.rmi.ConnectException(
                Messages.getString("rmi.80", toString()), ce); //$NON-NLS-1$
    } catch (IOException ioe) {
        throw new ConnectIOException(
                Messages.getString("rmi.80", toString()), ioe); //$NON-NLS-1$
    }
    return s;
}
项目:freeVM    文件:ClientConnection.java   
/**
 * Writes RMI protocol header and RMI protocol version to the open
 * OutputStream.
 *
 * @param dout DataOutputStream to write header to
 *
 * @throws RemoteException if any I/O error occurred while writing header
 */
protected void writeHeader(DataOutputStream dout) throws RemoteException {
    try {
        dout.writeInt(RMI_HEADER);
        dout.writeShort(PROTOCOL_VER);
    } catch (IOException ioe) {
        // rmi.41=Unable to write RMI protocol header
        throw new ConnectIOException(Messages.getString("rmi.41"), ioe); //$NON-NLS-1$
    }

    if (transportLog.isLoggable(RMILog.VERBOSE)) {
        // rmi.log.94=Using protocol version {0}
        transportLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.94", //$NON-NLS-1$
                PROTOCOL_VER));
    }
}
项目:freeVM    文件:Endpoint.java   
/**
 * Creates and returns socket.
 *
 * @return created socket
 */
public Socket createSocket() throws RemoteException {
    Socket s;

    try {
        s = DefaultRMISocketFactory.getNonNullClientFactory(csf)
                .createSocket(host, port);
    } catch (java.net.UnknownHostException uhe) {
        // rmi.80=Unable to connect to server {0}
        throw new java.rmi.UnknownHostException(
                Messages.getString("rmi.80", toString()), uhe); //$NON-NLS-1$
    } catch (java.net.ConnectException ce) {
        throw new java.rmi.ConnectException(
                Messages.getString("rmi.80", toString()), ce); //$NON-NLS-1$
    } catch (IOException ioe) {
        throw new ConnectIOException(
                Messages.getString("rmi.80", toString()), ioe); //$NON-NLS-1$
    }
    return s;
}
项目:OpenJSharp    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:openjdk-jdk10    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:openNaEF    文件:ExceptionUtils.java   
public static boolean isLocalProblem(RemoteException e) {
    if (e instanceof ConnectIOException) {
        return true;
    } else if (e instanceof ConnectException) {
        return true;
    } else if (e instanceof UnknownHostException) {
        return true;
    }
    return false;
}
项目:openjdk9    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:jdk8u_jdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:incubator-taverna-server    文件:ForkRunFactory.java   
private RemoteRunFactory getRemoteFactoryHandle(String name)
        throws RemoteException, NotBoundException {
    log.info("about to look up resource called " + name);
    try {
        // Validate registry connection first
        getTheRegistry().list();
    } catch (ConnectException | ConnectIOException e) {
        log.warn("connection problems with registry", e);
    }
    RemoteRunFactory rrf = (RemoteRunFactory) getTheRegistry().lookup(name);
    log.info("successfully connected to factory subprocess "
            + factoryProcessName);
    return rrf;
}
项目:infobip-open-jdk-8    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:jdk8u-dev-jdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:jdk7-jdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:openjdk-source-code-learn    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:OLD-OpenJDK8    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:cn1    文件:HttpConnection.java   
/**
 * Acknowledge protocol with server side.
 *
 * @return acknowledged protocol number
 *
 * @throws RemoteException if any I/O exception occurred during protocol
 *         acknowledgement
 */
protected int serverProtocolAck() throws RemoteException {
    try {
        DataOutputStream dout = new DataOutputStream(out);

        // write RMI header and protocol version
        writeHeader(dout);

        // write protocol type
        dout.writeByte(SINGLEOP_PROTOCOL);
        dout.flush();

        if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
            // rmi.log.130=Using singleop RMI protocol
            proxyTransportLog.log(RMILog.VERBOSE,Messages.getString("rmi.log.130")); //$NON-NLS-1$
        }
        dout.flush();
    } catch (RemoteException re) {
        close();
        throw re;
    } catch (IOException ioe) {
        close();
        // rmi.8E=Unable to acknowledge protocol with server
        throw new ConnectIOException(Messages.getString("rmi.8E"), ioe); //$NON-NLS-1$
    }

    // protocol is agreed
    return SINGLEOP_PROTOCOL;
}
项目:cn1    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectIOExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectIOException e = new ConnectIOException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:cn1    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String)}.
 */
public void testConnectIOExceptionString() {
    ConnectIOException e = new ConnectIOException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:openjdk-jdk7u-jdk    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:freeVM    文件:HttpConnection.java   
/**
 * Acknowledge protocol with server side.
 *
 * @return acknowledged protocol number
 *
 * @throws RemoteException if any I/O exception occurred during protocol
 *         acknowledgement
 */
protected int serverProtocolAck() throws RemoteException {
    try {
        DataOutputStream dout = new DataOutputStream(out);

        // write RMI header and protocol version
        writeHeader(dout);

        // write protocol type
        dout.writeByte(SINGLEOP_PROTOCOL);
        dout.flush();

        if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
            // rmi.log.130=Using singleop RMI protocol
            proxyTransportLog.log(RMILog.VERBOSE,Messages.getString("rmi.log.130")); //$NON-NLS-1$
        }
        dout.flush();
    } catch (RemoteException re) {
        close();
        throw re;
    } catch (IOException ioe) {
        close();
        // rmi.8E=Unable to acknowledge protocol with server
        throw new ConnectIOException(Messages.getString("rmi.8E"), ioe); //$NON-NLS-1$
    }

    // protocol is agreed
    return SINGLEOP_PROTOCOL;
}
项目:freeVM    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectIOExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectIOException e = new ConnectIOException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String)}.
 */
public void testConnectIOExceptionString() {
    ConnectIOException e = new ConnectIOException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:freeVM    文件:HttpConnection.java   
/**
 * Acknowledge protocol with server side.
 *
 * @return acknowledged protocol number
 *
 * @throws RemoteException if any I/O exception occurred during protocol
 *         acknowledgement
 */
protected int serverProtocolAck() throws RemoteException {
    try {
        DataOutputStream dout = new DataOutputStream(out);

        // write RMI header and protocol version
        writeHeader(dout);

        // write protocol type
        dout.writeByte(SINGLEOP_PROTOCOL);
        dout.flush();

        if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
            // rmi.log.130=Using singleop RMI protocol
            proxyTransportLog.log(RMILog.VERBOSE,Messages.getString("rmi.log.130")); //$NON-NLS-1$
        }
        dout.flush();
    } catch (RemoteException re) {
        close();
        throw re;
    } catch (IOException ioe) {
        close();
        // rmi.8E=Unable to acknowledge protocol with server
        throw new ConnectIOException(Messages.getString("rmi.8E"), ioe); //$NON-NLS-1$
    }

    // protocol is agreed
    return SINGLEOP_PROTOCOL;
}
项目:freeVM    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String, java.lang.Exception)}.
 */
public void testConnectIOExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    ConnectIOException e = new ConnectIOException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
项目:freeVM    文件:ConnectIOExceptionTest.java   
/**
 * {@link java.rmi.ConnectIOException#ConnectIOException(java.lang.String)}.
 */
public void testConnectIOExceptionString() {
    ConnectIOException e = new ConnectIOException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
项目:openjdk-icedtea7    文件:TCPChannel.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:HandshakeTimeout.java   
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);
                }
            }
        }
    }
项目:jdk8u-jdk    文件:HandshakeFailure.java   
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);
                }
            }
        }
    }
项目:openjdk-jdk10    文件:HandshakeTimeout.java   
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(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();

        /*
         * 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) {
                    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);
                }
            }
        }
    }