This commit is contained in:
Redkale
2017-11-14 10:54:56 +08:00
parent ac5662114a
commit e0b2120ee5

View File

@@ -134,7 +134,7 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
* @throws java.io.IOException 异常
*/
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
final int readTimeoutSecond, final int writeTimeoutSecond) throws IOException {
final int readTimeoutSecond, final int writeTimeoutSecond) {
return createTCP(group, address, false, readTimeoutSecond, writeTimeoutSecond);
}
@@ -148,11 +148,11 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
* @param writeTimeoutSecond 写入超时秒数
*
* @return 连接CompletableFuture
* @throws java.io.IOException 异常
*/
public static CompletableFuture<AsyncConnection> createTCP(final AsynchronousChannelGroup group, final SocketAddress address,
final boolean noDelay, final int readTimeoutSecond, final int writeTimeoutSecond) throws IOException {
final boolean noDelay, final int readTimeoutSecond, final int writeTimeoutSecond) {
final CompletableFuture future = new CompletableFuture();
try {
final AsynchronousSocketChannel channel = AsynchronousSocketChannel.open(group);
channel.connect(address, null, new CompletionHandler<Void, Void>() {
@Override
@@ -171,6 +171,9 @@ public abstract class AsyncConnection implements AsynchronousByteChannel, AutoCl
future.completeExceptionally(exc);
}
});
} catch (IOException e) {
future.completeExceptionally(e);
}
return future;
}