private static void connect(SelectionKey k) throws IOException { NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment(); try { if (ch.channel.finishConnect()) { k.cancel(); if (ch.timoutTimer != null) { ch.timoutTimer.cancel(); } ch.worker.register(ch, ch.connectFuture); } } catch (ConnectException e) { ConnectException newE = new ConnectException(e.getMessage() + ": " + ch.requestedRemoteAddress); newE.setStackTrace(e.getStackTrace()); throw newE; } }
@Override public final ConnectException couldNotConnect(final URI uri) { final ConnectException result = new ConnectException(String.format(getLoggingLocale(), couldNotConnect$str(), uri)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidByteToken = "WFLYPRT0030: Invalid byte token. Expecting '%d' received '%d'";
@Override public final ConnectException couldNotConnect(final URI uri) { final ConnectException result = new ConnectException(String.format(getLoggingLocale(), couldNotConnect$str(), uri)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String invalidByteToken = "WFLYPRT0030: Invalid byte token. Expecting '%d' received '%d'";
private static void connect(SelectionKey k) throws IOException { NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment(); try { if (ch.channel.finishConnect()) { k.cancel(); if (ch.timoutTimer != null) { ch.timoutTimer.cancel(); } ch.worker.register(ch, ch.connectFuture); } } catch (ConnectException e) { ConnectException newE = new ConnectException(e.getMessage() + ": " + ch.requestedRemoteAddress); newE.setStackTrace(e.getStackTrace()); throw newE; } }
private static void connect(SelectionKey k) throws IOException { NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment(); try { if (ch.channel.finishConnect()) { k.cancel(); if (ch.timoutTimer != null) { ch.timoutTimer.cancel(); } ch.worker.register(ch, ch.connectFuture); } } catch (ConnectException e) { ConnectException newE = new ConnectException(e.getMessage() + ": " + ch.requestedRemoteAddress); newE.setStackTrace(e.getStackTrace()); throw newE; } }
@Override public final ConnectException failedToConnect(final URI uri, final Exception cause) { final ConnectException result = new ConnectException(String.format(getLoggingLocale(), failedToConnect$str(), uri)); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String channelClosed = "WFLYPRT0054: Channel closed";
@Override public final ConnectException failedToConnect(final URI uri, final Exception cause) { final ConnectException result = new ConnectException(String.format(getLoggingLocale(), failedToConnect$str(), uri)); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String channelClosed = "WFLYPRT0054: Channel closed";
private static void connect(SelectionKey k) throws IOException { NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment(); try { if (ch.channel.finishConnect()) { k.cancel(); if (ch.timoutTimer != null) { ch.timoutTimer.cancel(); } ch.worker.register(ch, ch.connectFuture); } } catch (ConnectException e) { ConnectException newE = new ConnectException(e.getMessage() + ": " + ch.requestedRemoteAddress); newE.setStackTrace(e.getStackTrace()); throw newE; } }
private IOException translateException(HttpURLConnection connection, Exception exception) throws IOException { if (exception instanceof SocketTimeoutException) { //enhance message with timeout values if (exception.getMessage().equals("connect timed out")) { ConnectException cx = new ConnectException("Connect timeout " + connection.getConnectTimeout() + " ms"); cx.setStackTrace(exception.getStackTrace()); throw cx; } else if (exception.getMessage().equals("Read timed out")) { SocketTimeoutException stx = new SocketTimeoutException("Read timeout " + connection.getReadTimeout() + " ms"); stx.setStackTrace(exception.getStackTrace()); throw stx; } else { throw (SocketTimeoutException) exception; } } else if (exception instanceof ConnectException) { //enhance message with url ConnectException ctx = new ConnectException("Connection refused " + config.getUrl()); ctx.setStackTrace(exception.getStackTrace()); throw ctx; } else if (exception instanceof IOException) { throw (IOException) exception; } else { IOException iox = new IOException(exception.getMessage()); iox.setStackTrace(exception.getStackTrace()); throw iox; } }
cx.setStackTrace(x.getStackTrace()); throw cx; } else if (x instanceof ConnectTimeoutException) { ConnectException cx = new ConnectException("Connect timeout " + config.getConnectTimeoutMillis() + " ms"); cx.setStackTrace(x.getStackTrace()); throw cx; } else if (x instanceof SocketTimeoutException) { ctx.setStackTrace(x.getStackTrace()); throw ctx; } else if (x instanceof IOException) {
if (x instanceof ConnectionPoolTimeoutException) { ConnectException ctx = new ConnectException("Pool timeout " + config.getPoolAcquireTimeoutMillis() + " ms"); ctx.setStackTrace(x.getStackTrace()); throw ctx; } else if (x instanceof ConnectTimeoutException) { ConnectException ctx = new ConnectException("Connect timeout " + config.getConnectTimeoutMillis() + " ms"); ctx.setStackTrace(x.getStackTrace()); throw ctx; } else if (x instanceof HttpHostConnectException) { ctx.setStackTrace(x.getStackTrace()); throw ctx; } else if (x instanceof SocketTimeoutException) {
} else if (x instanceof SocketTimeoutException) { ConnectException cx = new ConnectException("Connect timeout " + config.getConnectTimeoutMillis() + " ms"); cx.setStackTrace(x.getStackTrace()); throw cx;