Skip to content

Commit 4322b4f

Browse files
authored
Using non-native transports with SocketOptions should cause an error (#3279)
* Using non-native transports with SocketOptions should cause an error * Add LettuceAssert.assertState Revert previous implement
1 parent 6d4bcfc commit 4322b4f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/io/lettuce/core/ConnectionBuilder.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,17 @@ public void configureBootstrap(boolean domainSocket,
276276

277277
SocketOptions.TcpUserTimeoutOptions tcpUserTimeoutOptions = options.getTcpUserTimeout();
278278

279+
boolean applied = false;
279280
if (IOUringProvider.isAvailable()) {
280281
IOUringProvider.applyTcpUserTimeout(bootstrap, tcpUserTimeoutOptions.getTcpUserTimeout());
282+
applied = true;
281283
} else if (io.lettuce.core.resource.EpollProvider.isAvailable()) {
282284
EpollProvider.applyTcpUserTimeout(bootstrap, tcpUserTimeoutOptions.getTcpUserTimeout());
283-
} else {
284-
logger.warn("Cannot apply TCP User Timeout options to channel type " + channelClass.getName());
285+
applied = true;
285286
}
287+
288+
LettuceAssert.assertState(applied,
289+
"TCP User Timeout options could not be applied. Native transports (io_uring or epoll) are required.");
286290
}
287291
}
288292

@@ -291,17 +295,22 @@ public void configureBootstrap(boolean domainSocket,
291295
if (options.isKeepAlive() && options.isExtendedKeepAlive()) {
292296

293297
SocketOptions.KeepAliveOptions keepAlive = options.getKeepAlive();
298+
boolean applied = false;
294299

295300
if (IOUringProvider.isAvailable()) {
296301
IOUringProvider.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(), keepAlive.getInterval());
302+
applied = true;
297303
} else if (io.lettuce.core.resource.EpollProvider.isAvailable()) {
298304
EpollProvider.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(), keepAlive.getInterval());
305+
applied = true;
299306
} else if (ExtendedNioSocketOptions.isAvailable() && !KqueueProvider.isAvailable()) {
300307
ExtendedNioSocketOptions.applyKeepAlive(bootstrap, keepAlive.getCount(), keepAlive.getIdle(),
301308
keepAlive.getInterval());
302-
} else {
303-
logger.warn("Cannot apply extended TCP keepalive options to channel type " + channelClass.getName());
309+
applied = true;
304310
}
311+
312+
LettuceAssert.assertState(applied,
313+
"Extended TCP keepalive options could not be applied. Native transports (io_uring or epoll) or a compatible NIO transport are required.");
305314
}
306315

307316
}

0 commit comments

Comments
 (0)