java.net.ConnectException Java Examples
The following examples show how to use
java.net.ConnectException.
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: RetryWhenNetworkException.java From Bailan with Apache License 2.0 | 6 votes |
@Override public Observable<?> call(Observable<? extends Throwable> observable) { return observable .zipWith(Observable.range(1, count + 1), new Func2<Throwable, Integer, Wrapper>() { @Override public Wrapper call(Throwable throwable, Integer integer) { //压缩规则 合并后的结果是一个Observable<Wrapper> return new Wrapper(throwable, integer); } }).flatMap(new Func1<Wrapper, Observable<?>>() { @Override public Observable<?> call(Wrapper wrapper) { //转换规则 if ((wrapper.throwable instanceof ConnectException || wrapper.throwable instanceof SocketTimeoutException || wrapper.throwable instanceof TimeoutException) && wrapper.index < count + 1) { //如果超出重试次数也抛出错误,否则默认是会进入onCompleted return Observable.timer(delay + (wrapper.index - 1) * increaseDelay, TimeUnit.MILLISECONDS); } return Observable.error(wrapper.throwable); } }); }
Example #2
Source File: HwvtepDataChangeListener.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
private void connect(Collection<DataTreeModification<Node>> changes) { for (DataTreeModification<Node> change : changes) { final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier(); final DataObjectModification<Node> mod = change.getRootNode(); Node node = getCreated(mod); if (node != null) { HwvtepGlobalAugmentation hwvtepGlobal = node.augmentation(HwvtepGlobalAugmentation.class); // We can only connect if user configured connection info if (hwvtepGlobal != null && hwvtepGlobal.getConnectionInfo() != null) { ConnectionInfo connection = hwvtepGlobal.getConnectionInfo(); InstanceIdentifier<Node> iid = hcm.getInstanceIdentifier(connection); if (iid != null) { LOG.warn("Connection to device {} already exists. Plugin does not allow multiple connections " + "to same device, hence dropping the request {}", connection, hwvtepGlobal); } else { try { hcm.connect(key, hwvtepGlobal); } catch (UnknownHostException | ConnectException e) { LOG.warn("Failed to connect to HWVTEP node", e); } } } } } }
Example #3
Source File: InitialDevices.java From onvif-java-lib with Apache License 2.0 | 6 votes |
public Profile createProfile(String name) { CreateProfile request = new CreateProfile(); CreateProfileResponse response = new CreateProfileResponse(); request.setName(name); try { response = (CreateProfileResponse) soap.createSOAPMediaRequest(request, response, true); } catch (SOAPException | ConnectException e) { e.printStackTrace(); return null; } if (response == null) { return null; } return response.getProfile(); }
Example #4
Source File: SetupViewModel.java From lttrs-android with Apache License 2.0 | 6 votes |
private String causeToString(Throwable t) { final Context c = getApplication(); if (t instanceof InvalidSessionResourceException) { return c.getString(R.string.invalid_session_resource); } if (t instanceof EndpointNotFoundException) { return c.getString(R.string.endpoint_not_found); } if (t instanceof ConnectException) { return c.getString(R.string.unable_to_connect); } if (t instanceof SocketTimeoutException) { return c.getString(R.string.timeout_reached); } if (t instanceof SSLHandshakeException) { return c.getString(R.string.unable_to_establish_secure_connection); } if (t instanceof SSLPeerUnverifiedException) { return c.getString(R.string.unable_to_verify_service_identity); } throw new IllegalArgumentException(); }
Example #5
Source File: TestNetUtils.java From hadoop with Apache License 2.0 | 6 votes |
/** * Test that we can't accidentally connect back to the connecting socket due * to a quirk in the TCP spec. * * This is a regression test for HADOOP-6722. */ @Test public void testAvoidLoopbackTcpSockets() throws Exception { Configuration conf = new Configuration(); Socket socket = NetUtils.getDefaultSocketFactory(conf) .createSocket(); socket.bind(new InetSocketAddress("127.0.0.1", 0)); System.err.println("local address: " + socket.getLocalAddress()); System.err.println("local port: " + socket.getLocalPort()); try { NetUtils.connect(socket, new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort()), 20000); socket.close(); fail("Should not have connected"); } catch (ConnectException ce) { System.err.println("Got exception: " + ce); assertTrue(ce.getMessage().contains("resulted in a loopback")); } catch (SocketException se) { // Some TCP stacks will actually throw their own Invalid argument exception // here. This is also OK. assertTrue(se.getMessage().contains("Invalid argument")); } }
Example #6
Source File: RetryWhenNetworkException.java From Rx-Retrofit with MIT License | 6 votes |
@Override public Observable<?> call(Observable<? extends Throwable> observable) { return observable .zipWith(Observable.range(1, count + 1), new Func2<Throwable, Integer, Wrapper>() { @Override public Wrapper call(Throwable throwable, Integer integer) { return new Wrapper(throwable, integer); } }).flatMap(new Func1<Wrapper, Observable<?>>() { @Override public Observable<?> call(Wrapper wrapper) { if ((wrapper.throwable instanceof ConnectException || wrapper.throwable instanceof SocketTimeoutException || wrapper.throwable instanceof TimeoutException) && wrapper.index < count + 1) { //如果超出重试次数也抛出错误,否则默认是会进入onCompleted return Observable.timer(delay + (wrapper.index - 1) * increaseDelay, TimeUnit.MILLISECONDS); } return Observable.error(wrapper.throwable); } }); }
Example #7
Source File: RealConnection.java From AndroidProjects with MIT License | 6 votes |
/** Does all the work necessary to build a full HTTP or HTTPS connection on a raw socket. */ private void connectSocket(int connectTimeout, int readTimeout) throws IOException { Proxy proxy = route.proxy(); Address address = route.address(); rawSocket = proxy.type() == Proxy.Type.DIRECT || proxy.type() == Proxy.Type.HTTP ? address.socketFactory().createSocket() : new Socket(proxy); rawSocket.setSoTimeout(readTimeout); try { Platform.get().connectSocket(rawSocket, route.socketAddress(), connectTimeout); } catch (ConnectException e) { ConnectException ce = new ConnectException("Failed to connect to " + route.socketAddress()); ce.initCause(e); throw ce; } source = Okio.buffer(Okio.source(rawSocket)); sink = Okio.buffer(Okio.sink(rawSocket)); }
Example #8
Source File: MediaDevices.java From onvif-java-lib with Apache License 2.0 | 6 votes |
public String getSnapshotUri(String profileToken) throws SOAPException, ConnectException { GetSnapshotUri request = new GetSnapshotUri(); GetSnapshotUriResponse response = new GetSnapshotUriResponse(); request.setProfileToken(profileToken); try { response = (GetSnapshotUriResponse) soap.createSOAPMediaRequest(request, response, true); } catch (SOAPException | ConnectException e) { throw e; } if (response == null || response.getMediaUri() == null) { return null; } return onvifDevice.replaceLocalIpWithProxyIp(response.getMediaUri().getUri()); }
Example #9
Source File: PtzDevices.java From onvif-java-lib with Apache License 2.0 | 6 votes |
public PTZStatus getStatus(String profileToken) { GetStatus request = new GetStatus(); GetStatusResponse response = new GetStatusResponse(); request.setProfileToken(profileToken); try { response = (GetStatusResponse) soap.createSOAPPtzRequest(request, response, false); } catch (SOAPException | ConnectException e) { e.printStackTrace(); return null; } if (response == null) { return null; } return response.getPTZStatus(); }
Example #10
Source File: ConnectionReconciliationTask.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
@Override public boolean reconcileConfiguration(final OvsdbConnectionManager connectionManagerOfDevice) { boolean result = false; connectionAttempt.incrementAndGet(); InstanceIdentifier<Node> ndIid = (InstanceIdentifier<Node>) nodeIid; OvsdbNodeAugmentation ovsdbNode = (OvsdbNodeAugmentation)configData; LOG.info("Retry({}) connection to Ovsdb Node {} ", connectionAttempt.get(), ovsdbNode.getConnectionInfo()); OvsdbClient client = null; try { client = connectionManagerOfDevice.connect(ndIid, ovsdbNode); if (client != null) { LOG.info("Successfully connected to Ovsdb Node {} ", ovsdbNode.getConnectionInfo()); result = true; } else { LOG.warn("Connection retry({}) failed for {}.", connectionAttempt.get(), ovsdbNode.getConnectionInfo()); } } catch (UnknownHostException | ConnectException e) { LOG.warn("Connection retry({}) failed with exception. ",connectionAttempt.get(), e); } return result; }
Example #11
Source File: BpmSourceAndProcessSelectorTest.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
protected <A> Answer getPAMInstanceAnswer(A validAnswer) { return invocation -> { KieBpmConfig config = invocation.getArgument(0); switch (config.getName()) { case "default": return Arrays.asList(validAnswer); case "broken": throw new ApsSystemException("", new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR)); case "unreachable": throw new ApsSystemException("", new ConnectException()); default: return null; } }; }
Example #12
Source File: TestTimelineClient.java From big-c with Apache License 2.0 | 6 votes |
private static ClientResponse mockEntityClientResponse( TimelineClientImpl client, ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) { ClientResponse response = mock(ClientResponse.class); if (hasRuntimeError) { doThrow(new ClientHandlerException(new ConnectException())).when(client) .doPostingObject(any(TimelineEntities.class), any(String.class)); return response; } doReturn(response).when(client) .doPostingObject(any(TimelineEntities.class), any(String.class)); when(response.getClientResponseStatus()).thenReturn(status); TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError(); error.setEntityId("test entity id"); error.setEntityType("test entity type"); error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION); TimelinePutResponse putResponse = new TimelinePutResponse(); if (hasError) { putResponse.addError(error); } when(response.getEntity(TimelinePutResponse.class)).thenReturn(putResponse); return response; }
Example #13
Source File: ErrorHandler.java From apiman with Apache License 2.0 | 6 votes |
/** * This method handles a connection error that was caused while connecting the gateway to the backend. * * @param error the connection error to be handled * @return a new ConnectorException */ public static ConnectorException handleConnectionError(Throwable error) { ConnectorException ce = null; if (error instanceof UnknownHostException || error instanceof ConnectException || error instanceof NoRouteToHostException) { ce = new ConnectorException("Unable to connect to backend", error); //$NON-NLS-1$ ce.setStatusCode(502); // BAD GATEWAY } else if (error instanceof InterruptedIOException || error instanceof java.util.concurrent.TimeoutException) { ce = new ConnectorException("Connection to backend terminated" + error.getMessage(), error); //$NON-NLS-1$ ce.setStatusCode(504); // GATEWAY TIMEOUT } if (ce != null) { return ce; } else { return new ConnectorException(error.getMessage(), error); } }
Example #14
Source File: CarreraAsyncRequest.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public void onThrowable(Throwable t) { inflightRequests.remove(this); job.setState("HTTP.onThrowable"); MetricUtils.httpRequestLatencyMetric(job, TimeUtils.getElapseTime(startTime)); MetricUtils.httpRequestFailureMetric(job, null); String errorLog = String.format("Action Result: HttpAccess[result:exception,url:%s,request:%s,used:%d],Exception:%s|%s", getUrl(), this, TimeUtils.getElapseTime(startTime), t.getClass().getSimpleName(), t.getMessage()); if (t instanceof ConnectException || t instanceof TimeoutException) { LOGGER.info(errorLog); } else { LogUtils.logErrorInfo("CarreraAsyncRequest_error", errorLog, t); } delayRetryRequest(DEFAULT_RETRY_DELAY << Math.min(job.getErrorRetryCnt(), MAX_RETRY_DELAY_FACTOR)); job.incErrorRetryCnt(); }
Example #15
Source File: ChannelManagerImplTest.java From xenqtt with Apache License 2.0 | 6 votes |
@Test public void testNewClientChannel_UnableToConnect_Blocking() throws Exception { manager = new ChannelManagerImpl(2, 0); manager.init(); CountDownLatch trigger = new CountDownLatch(1); clientHandler.onChannelClosed(trigger); try { clientChannel = manager.newClientChannel("localhost", 19876, clientHandler); fail("expected exception"); } catch (MqttInvocationException e) { } assertTrue(trigger.await(1000, TimeUnit.SECONDS)); clientHandler.assertLastChannelClosedCause(ConnectException.class); }
Example #16
Source File: RemoterHA.java From jumbune with GNU Lesser General Public License v3.0 | 6 votes |
/** * Write to channel. * * @param channel the channel * @param magicBytes the magic bytes * @param pathOrCommand the path or command * @param attachment the attachment */ private void writeToChannel(Channel channel, String[] magicBytes, Object pathOrCommand, Object attachment) throws ConnectException { long firstAttempt = System.currentTimeMillis(); long timeOut = RemotingConstants.TEN * RemotingConstants.THOUSAND; while (!channel.isOpen() || !channel.isActive()) { if (System.currentTimeMillis() - firstAttempt >= timeOut) { try { throw new TimeoutException(); } catch (TimeoutException e) { logger.error("Waited for 10 sec for connection reattempt to JumbuneAgent, but failed to connect", e); } break; } } if (!channel.isActive()) { logger.warn("channel #" + channel.hashCode() + " still disconnected, about to write on disconnected Channel"); } if (attachment != null && attachment instanceof CyclicBarrier) { channel.attr(RemotingConstants.barrierKey).set((CyclicBarrier)attachment); }else if (attachment != null) { channel.attr(RemotingConstants.handlerKey).set((ChannelInboundHandler)attachment); } channel.write(Unpooled.wrappedBuffer(magicBytes[0].getBytes(), magicBytes[1].getBytes(), magicBytes[2].getBytes())); channel.write(pathOrCommand); channel.flush(); }
Example #17
Source File: ExceptionDiags.java From hadoop with Apache License 2.0 | 6 votes |
/** * Take an IOException and a URI, wrap it where possible with * something that includes the URI * * @param dest target URI * @param operation operation * @param exception the caught exception. * @return an exception to throw */ public static IOException wrapException(final String dest, final String operation, final IOException exception) { String action = operation + " " + dest; String xref = null; if (exception instanceof ConnectException) { xref = "ConnectionRefused"; } else if (exception instanceof UnknownHostException) { xref = "UnknownHost"; } else if (exception instanceof SocketTimeoutException) { xref = "SocketTimeout"; } else if (exception instanceof NoRouteToHostException) { xref = "NoRouteToHost"; } String msg = action + " failed on exception: " + exception; if (xref != null) { msg = msg + ";" + see(xref); } return wrapWithMessage(exception, msg); }
Example #18
Source File: ImagingDevices.java From onvif-java-lib with Apache License 2.0 | 6 votes |
public boolean setImagingSettings(String videoSourceToken, ImagingSettings20 imagingSettings) { if (videoSourceToken == null) { return false; } SetImagingSettings request = new SetImagingSettings(); SetImagingSettingsResponse response = new SetImagingSettingsResponse(); request.setVideoSourceToken(videoSourceToken); request.setImagingSettings(imagingSettings); try { response = (SetImagingSettingsResponse) soap.createSOAPImagingRequest(request, response, true); } catch (SOAPException | ConnectException e) { e.printStackTrace(); return false; } if (response == null) { return false; } return true; }
Example #19
Source File: NioClientBoss.java From simple-netty-source with Apache License 2.0 | 6 votes |
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; } }
Example #20
Source File: NetworkUtils.java From submarine with Apache License 2.0 | 6 votes |
public static boolean checkIfRemoteEndpointAccessible(String host, int port) { try { Socket discover = new Socket(); discover.setSoTimeout(1000); discover.connect(new InetSocketAddress(host, port), 1000); discover.close(); return true; } catch (ConnectException cne) { // end point is not accessible if (LOG.isDebugEnabled()) { LOG.debug("Remote endpoint '" + host + ":" + port + "' is not accessible " + "(might be initializing): " + cne.getMessage()); } return false; } catch (IOException ioe) { // end point is not accessible if (LOG.isDebugEnabled()) { LOG.debug("Remote endpoint '" + host + ":" + port + "' is not accessible " + "(might be initializing): " + ioe.getMessage()); } return false; } }
Example #21
Source File: StreamClientImpl.java From onos with Apache License 2.0 | 6 votes |
@Override public void onError(Throwable throwable) { if (throwable instanceof StatusRuntimeException) { final StatusRuntimeException sre = (StatusRuntimeException) throwable; if (sre.getStatus().getCause() instanceof ConnectException) { log.warn("{} is unreachable ({})", deviceId, sre.getCause().getMessage()); } else { log.warn("Error on StreamChannel RPC for {}: {}", deviceId, throwable.getMessage()); } log.debug("", throwable); } else { log.error(format("Exception on StreamChannel RPC for %s", deviceId), throwable); } streamChannelManager.teardown(); }
Example #22
Source File: OvsdbConnectionManager.java From ovsdb with Eclipse Public License 1.0 | 6 votes |
public OvsdbClient connect(final InstanceIdentifier<Node> iid, final OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException, ConnectException { LOG.info("Connecting to {}", SouthboundUtil.connectionInfoToString(ovsdbNode.getConnectionInfo())); // TODO handle case where we already have a connection // TODO use transaction chains to handle ordering issues between disconnected // TODO and connected when writing to the operational store InetAddress ip = SouthboundMapper.createInetAddress(ovsdbNode.getConnectionInfo().getRemoteIp()); OvsdbClient client = ovsdbConnection.connect(ip, ovsdbNode.getConnectionInfo().getRemotePort().getValue().toJava()); // For connections from the controller to the ovs instance, the library doesn't call // this method for us if (client != null) { putInstanceIdentifier(ovsdbNode.getConnectionInfo(), iid.firstIdentifierOf(Node.class)); OvsdbConnectionInstance ovsdbConnectionInstance = connectedButCallBacksNotRegistered(client); ovsdbConnectionInstance.setOvsdbNodeAugmentation(ovsdbNode); // Register Cluster Ownership for ConnectionInfo registerEntityForOwnership(ovsdbConnectionInstance); } else { LOG.warn("Failed to connect to OVSDB Node {}", ovsdbNode.getConnectionInfo()); } return client; }
Example #23
Source File: ExtendedWorker.java From rapidoid with Apache License 2.0 | 6 votes |
@Override protected void connectOP(SelectionKey key) throws IOException { U.must(key.isConnectable()); SocketChannel socketChannel = (SocketChannel) key.channel(); if (!socketChannel.isConnectionPending()) { // not ready to retrieve the connection status return; } ConnectionTarget target = (ConnectionTarget) key.attachment(); boolean ready; try { ready = socketChannel.finishConnect(); U.must(ready, "Expected an established connection!"); Log.info("Connected", "address", target.addr); connected.add(new RapidoidChannel(socketChannel, true, target.protocol, target.holder, target.reconnecting, target.state)); } catch (ConnectException e) { retryConnecting(target); } }
Example #24
Source File: SocketConnectionAttemptTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
private static void testConnectRefused0(Bootstrap cb, boolean halfClosure) throws Throwable { final Promise<Error> errorPromise = GlobalEventExecutor.INSTANCE.newPromise(); ChannelHandler handler = new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { errorPromise.setFailure(new AssertionError("should have never been called")); } }; cb.handler(handler); cb.option(ChannelOption.ALLOW_HALF_CLOSURE, halfClosure); ChannelFuture future = cb.connect(NetUtil.LOCALHOST, UNASSIGNED_PORT).awaitUninterruptibly(); assertThat(future.cause(), is(instanceOf(ConnectException.class))); assertThat(errorPromise.cause(), is(nullValue())); }
Example #25
Source File: GitlabExceptionHandler.java From mylyn-gitlab with Eclipse Public License 1.0 | 5 votes |
public static GitlabException handle(Throwable e) { if(e instanceof SSLHandshakeException) { return new GitlabException("Invalid TLS Certificate: " + e.getMessage()); } else if(e instanceof ConnectException) { return new GitlabException("Connection refused"); } else if(e instanceof NoRouteToHostException) { return new GitlabException("No route to host"); } else if(e instanceof FileNotFoundException) { return new GitlabException("Invalid path in host"); } else if(e instanceof IOException) { return new GitlabException("Invalid username/password/private token combination"); } return new GitlabException("Unknown Exception: " + e.getMessage()); }
Example #26
Source File: HessianClientInterceptor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Convert the given Hessian access exception to an appropriate * Spring RemoteAccessException. * @param ex the exception to convert * @return the RemoteAccessException to throw */ protected RemoteAccessException convertHessianAccessException(Throwable ex) { if (ex instanceof HessianConnectionException || ex instanceof ConnectException) { return new RemoteConnectFailureException( "Cannot connect to Hessian remote service at [" + getServiceUrl() + "]", ex); } else { return new RemoteAccessException( "Cannot access Hessian remote service at [" + getServiceUrl() + "]", ex); } }
Example #27
Source File: LocalRaftServerProtocol.java From atomix with Apache License 2.0 | 5 votes |
CompletableFuture<byte[]> leave(byte[] request) { if (leaveHandler != null) { return leaveHandler.apply(decode(request)).thenApply(this::encode); } else { return Futures.exceptionalFuture(new ConnectException()); } }
Example #28
Source File: AdvancedSubscriber.java From XiaoxiaZhihu with Apache License 2.0 | 5 votes |
private void doHandleException(Throwable throwable) { AppLog.d(this + "....doHandleException"); if (throwable != null) { AppLog.e("AdvancedSubscriber.doHandleException throwable = " + throwable.getMessage(), throwable); } String toastText = null; if (throwable instanceof AppException) { AppException appException = (AppException) throwable; Throwable detailException = appException.getDetailThrowable(); if (detailException instanceof ConnectException) { toastText = "Connect Fail"; } else if (detailException instanceof UnknownHostException) { toastText = "Unknown Host"; } else if (detailException instanceof TimeoutException || detailException instanceof InterruptedIOException) { toastText = "Time out"; } else if (detailException instanceof JSONException) { toastText = "Json error"; } else if (detailException instanceof JsonParseException) { toastText = "Gson parse error"; } } if (TextUtils.isEmpty(toastText)) { showToast(R.string.network_disable); } else { showToast("[" + toastText + "]"); } }
Example #29
Source File: NetExceptionHandle.java From WanAndroid with Apache License 2.0 | 5 votes |
/** * 处理异常错误 * @param context * @param t */ public static void dealException(Context context, Throwable t) { if (!NetworkUtils.isAvailable(context)){ onException(NetConfig.CONNECT_ERROR, context); return; } if (t instanceof ConnectException) { //连接错误,网络异常 onException(NetConfig.CONNECT_ERROR, context); }else if (t instanceof UnknownHostException){ //无法连接到主机 onException(NetConfig.UNKNOWN_HOST,context); } else if (t instanceof InterruptedException) { //连接超时 onException(NetConfig.CONNECT_TIMEOUT, context); } else if (t instanceof JSONException || t instanceof ParseException) { //解析错误 onException(NetConfig.PARSE_ERROR, context); } else if (t instanceof SocketTimeoutException) { //请求超时 onException(NetConfig.REQUEST_TIMEOUT, context); } else if (t instanceof UnknownError) { //未知错误 onException(NetConfig.UNKNOWN_ERROR, context); } else if (t instanceof IllegalArgumentException){ //未知错误 onException(NetConfig.ILLEGAL_PARAMS, context); } }
Example #30
Source File: LocalRaftServerProtocol.java From atomix with Apache License 2.0 | 5 votes |
CompletableFuture<byte[]> transfer(byte[] request) { if (transferHandler != null) { return transferHandler.apply(decode(request)).thenApply(this::encode); } else { return Futures.exceptionalFuture(new ConnectException()); } }