Skip to content

Commit ed9e1d5

Browse files
committed
Deprecate SOCKET_TIMEOUT option
Motivation: The SOCKET_TIMEOUT option has been identified as a NO-OP, meaning it has no effect on the underlying connection. To reduce confusion and potential issues for users, it is necessary to deprecate this option. Modification: Added a deprecation annotation to the SOCKET_TIMEOUT option and included a log warning message to inform users that the option is not supported and will be ignored. Result: The SOCKET_TIMEOUT option is now marked as deprecated, and users will be notified with a log warning message if they attempt to use it. This change encourages users to remove any references to SOCKET_TIMEOUT in their code.
1 parent 097f5b5 commit ed9e1d5

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
112112
.option(PASSWORD, "database-password-in-here") // optional, default null, null means has no password
113113
.option(DATABASE, "r2dbc") // optional, default null, null means not specifying the database
114114
.option(CONNECT_TIMEOUT, Duration.ofSeconds(3)) // optional, default null, null means no timeout
115-
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4)) // optional, default null, null means no timeout
115+
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4)) // deprecated since 0.9.2, because it has no effect and serves no purpose.
116116
.option(SSL, true) // optional, default sslMode is "preferred", it will be ignore if sslMode is set
117117
.option(Option.valueOf("sslMode"), "verify_identity") // optional, default "preferred"
118118
.option(Option.valueOf("sslCa"), "/path/to/mysql/ca.pem") // required when sslMode is verify_ca or verify_identity, default null, null means has no server CA cert

src/main/java/io/asyncer/r2dbc/mysql/MySqlConnectionConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ Duration getConnectTimeout() {
145145
return connectTimeout;
146146
}
147147

148+
/**
149+
* @deprecated This option has been deprecated as of version 0.9.2, because it has no effect and serves no purpose.
150+
* Please remove any references to this option from your code, as it will be removed in a future release.
151+
*/
148152
@Nullable
153+
@Deprecated
149154
Duration getSocketTimeout() {
150155
return socketTimeout;
151156
}

src/main/java/io/asyncer/r2dbc/mysql/MySqlConnectionFactoryProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
141141
* TCP socket timeout
142142
*
143143
* @since 0.8.3
144+
* @deprecated This option has been deprecated as of version 0.9.2, because it has no effect and serves no purpose.
145+
* Please remove any references to this option from your code, as it will be removed in a future release.
144146
*/
147+
@Deprecated
145148
public static final Option<Duration> SOCKET_TIMEOUT = Option.valueOf("socketTimeout");
146149

147150
/**

src/main/java/io/asyncer/r2dbc/mysql/client/Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import reactor.core.publisher.Mono;
2727
import reactor.core.publisher.SynchronousSink;
2828
import reactor.netty.tcp.TcpClient;
29+
import reactor.util.Logger;
30+
import reactor.util.Loggers;
2931
import reactor.util.annotation.Nullable;
3032

3133
import java.net.InetSocketAddress;
@@ -39,6 +41,7 @@
3941
* An abstraction that wraps the networking part of exchanging methods.
4042
*/
4143
public interface Client {
44+
Logger logger = Loggers.getLogger(Client.class);
4245

4346
/**
4447
* Perform an exchange of a request message. Calling this method while a previous exchange is active will
@@ -133,8 +136,7 @@ static Mono<Client> connect(MySqlSslConfiguration ssl, SocketAddress address, bo
133136
}
134137

135138
if (socketTimeout != null) {
136-
tcpClient = tcpClient.option(ChannelOption.SO_TIMEOUT,
137-
Math.toIntExact(socketTimeout.toMillis()));
139+
logger.warn("Socket timeout is not supported by the underlying connection and will be ignored.");
138140
}
139141

140142
if (address instanceof InetSocketAddress) {

0 commit comments

Comments
 (0)