Package java.net

Examples of java.net.NoRouteToHostException


    // Test for method java.net.NoRouteToHostException(java.lang.String)
    // Cannot test correctly without changing some routing tables !!

    try {
      if (true)
        throw new NoRouteToHostException("test");
    } catch (NoRouteToHostException e) {
      assertEquals("Threw exception with incorrect message", "test", e.getMessage()
          );
      return;
    }
View Full Code Here


              + " failed on socket timeout exception: " + exception
              + ";"
              + see("SocketTimeout"))
          .initCause(exception);
    } else if (exception instanceof NoRouteToHostException) {
      return (NoRouteToHostException) new NoRouteToHostException(
          "No Route to Host from  "
              + localHost + " to " + destHost + ":" + destPort
              + " failed on socket timeout exception: " + exception
              + ";"
              + see("NoRouteToHost"))
View Full Code Here

              + " failed on socket timeout exception: " + exception
              + ";"
              + see("SocketTimeout"))
          .initCause(exception);
    } else if (exception instanceof NoRouteToHostException) {
      return (NoRouteToHostException) new NoRouteToHostException(
          "No Route to Host from  "
              + localHost + " to " + destHost + ":" + destPort
              + " failed on socket timeout exception: " + exception
              + ";"
              + see("NoRouteToHost"))
View Full Code Here

                    String msg = Messages.getString("rmi.log.116") + host + ':' + port //$NON-NLS-1$
                            + ']';
                    if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                        proxyTransportLog.log(RMILog.BRIEF, msg);
                    }
                    throw new NoRouteToHostException(msg);
                }
            } else { // Both direct and HTTP connections are available.
                s = null;
                IOException ex = null;

                try {
                    s = directRsf.createSocket(host, port, (int) connTimeout);
                } catch (IOException ioe) {
                    ex = ioe;
                }

                if (s == null) {
                    // Direct socket attempt failed.
                    if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                        // rmi.log.117=Direct socket connection to [{0}:{1}] failed.
                        proxyTransportLog.log(RMILog.BRIEF, Messages.getString(
                                "rmi.log.117", host, port)); //$NON-NLS-1$
                    }

                    if (ex != null) {
                        if ((eagerHttpFallback
                                && !(ex instanceof SocketException))
                                || (!eagerHttpFallback
                                    && !(ex instanceof UnknownHostException)
                                    && !(ex instanceof NoRouteToHostException))) {
                            throw ex;
                        } else {
                            if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
                                // rmi.log.118=Trying proxy connection to [{1}:{1}].
                                proxyTransportLog.log(RMILog.VERBOSE,
                                        Messages.getString("rmi.log.118", //$NON-NLS-1$
                                        host, port ));
                            } // Falling through to HTTP connection attempt.
                        }
                    } else {
                        // rmi.95=Connection to [{0}:{1}] timed out
                        throw new NoRouteToHostException(Messages.getString("rmi.95", //$NON-NLS-1$
                                host, port));
                    }
                } else if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                    // rmi.log.11A=Direct socket connection to [{0}:{1}] from port {2} succeeded.
                    proxyTransportLog.log(RMILog.BRIEF,
                            Messages.getString("rmi.log.11A", new Object[]{host, port, s.getLocalPort()})); //$NON-NLS-1$
                }
            }
        }

        // Either disableDirectSocket or fallback from direct connection attempt.
        if (s == null) {
            s = proxyRsf.createSocket(proxy, host, port);

            if (s == null) {
                // rmi.log.11B=Proxy connection to [{0}:{1}] failed
                String msg = Messages.getString("rmi.log.11B", host, port); //$NON-NLS-1$
                if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                    proxyTransportLog.log(RMILog.BRIEF, msg);
                }

                throw new NoRouteToHostException(msg);
            }

            if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                // rmi.log.11C=Proxy connection to [{0}:{1}] from port {2} succeeded.
                proxyTransportLog.log(RMILog.BRIEF,Messages.getString("rmi.log.11C", //$NON-NLS-1$
View Full Code Here

            return new Socket(proxyHost, proxyPort);
        } else if (enableDirect) {
            return new Socket(host, port);
        } else {
            // rmi.81=HTTP proxy is not set
            throw new NoRouteToHostException(Messages.getString("rmi.81")); //$NON-NLS-1$
        }
    }
View Full Code Here

              + " failed on socket timeout exception: " + exception
              + ";"
              + see("SocketTimeout"))
          .initCause(exception);
    } else if (exception instanceof NoRouteToHostException) {
      return (NoRouteToHostException) new NoRouteToHostException(
          "No Route to Host from  "
              + localHost + " to " + destHost + ":" + destPort
              + " failed on socket timeout exception: " + exception
              + ";"
              + see("NoRouteToHost"))
View Full Code Here

  }

  @Test
  public void testException() throws Throwable {
    Exception e =
        new NoRouteToHostException("that box caught fire 3 years ago");
    ThrowableInformation ti = new ThrowableInformation(e);
    Log4Json l4j = new Log4Json();
    long timeStamp = System.currentTimeMillis();
    String outcome = l4j.toJson(new StringWriter(),
        "testException",
View Full Code Here

  }

  @Test
  public void testNestedException() throws Throwable {
    Exception e =
        new NoRouteToHostException("that box caught fire 3 years ago");
    Exception ioe = new IOException("Datacenter problems", e);
    ThrowableInformation ti = new ThrowableInformation(ioe);
    Log4Json l4j = new Log4Json();
    long timeStamp = System.currentTimeMillis();
    String outcome = l4j.toJson(new StringWriter(),
View Full Code Here

                    String msg = Messages.getString("rmi.log.116") + host + ':' + port //$NON-NLS-1$
                            + ']';
                    if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                        proxyTransportLog.log(RMILog.BRIEF, msg);
                    }
                    throw new NoRouteToHostException(msg);
                }
            } else { // Both direct and HTTP connections are available.
                s = null;
                IOException ex = null;

                try {
                    s = directRsf.createSocket(host, port, (int) connTimeout);
                } catch (IOException ioe) {
                    ex = ioe;
                }

                if (s == null) {
                    // Direct socket attempt failed.
                    if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                        // rmi.log.117=Direct socket connection to [{0}:{1}] failed.
                        proxyTransportLog.log(RMILog.BRIEF, Messages.getString(
                                "rmi.log.117", host, port)); //$NON-NLS-1$
                    }

                    if (ex != null) {
                        if ((eagerHttpFallback
                                && !(ex instanceof SocketException))
                                || (!eagerHttpFallback
                                    && !(ex instanceof UnknownHostException)
                                    && !(ex instanceof NoRouteToHostException))) {
                            throw ex;
                        } else {
                            if (proxyTransportLog.isLoggable(RMILog.VERBOSE)) {
                                // rmi.log.118=Trying proxy connection to [{1}:{1}].
                                proxyTransportLog.log(RMILog.VERBOSE,
                                        Messages.getString("rmi.log.118", //$NON-NLS-1$
                                        host, port ));
                            } // Falling through to HTTP connection attempt.
                        }
                    } else {
                        // rmi.95=Connection to [{0}:{1}] timed out
                        throw new NoRouteToHostException(Messages.getString("rmi.95", //$NON-NLS-1$
                                host, port));
                    }
                } else if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                    // rmi.log.11A=Direct socket connection to [{0}:{1}] from port {2} succeeded.
                    proxyTransportLog.log(RMILog.BRIEF,
                            Messages.getString("rmi.log.11A", new Object[]{host, port, s.getLocalPort()})); //$NON-NLS-1$
                }
            }
        }

        // Either disableDirectSocket or fallback from direct connection attempt.
        if (s == null) {
            s = proxyRsf.createSocket(proxy, host, port);

            if (s == null) {
                // rmi.log.11B=Proxy connection to [{0}:{1}] failed
                String msg = Messages.getString("rmi.log.11B", host, port); //$NON-NLS-1$
                if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                    proxyTransportLog.log(RMILog.BRIEF, msg);
                }

                throw new NoRouteToHostException(msg);
            }

            if (proxyTransportLog.isLoggable(RMILog.BRIEF)) {
                // rmi.log.11C=Proxy connection to [{0}:{1}] from port {2} succeeded.
                proxyTransportLog.log(RMILog.BRIEF,Messages.getString("rmi.log.11C", //$NON-NLS-1$
View Full Code Here

     * @tests java.net.NoRouteToHostException#NoRouteToHostException()
     */
    public void test_Constructor() {
        try {
            if (true) {
                throw new NoRouteToHostException();
            }
            fail("Failed to generate expected exception");
        } catch (NoRouteToHostException e) {
            // Expected
        }
View Full Code Here

TOP

Related Classes of java.net.NoRouteToHostException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.