Skip to content

Commit e9d7228

Browse files
authored
Deprecate SOCKET_TIMEOUT option (#95)
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 4fc27a3 commit e9d7228

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 1.0.1, 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 1.0.1, 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 1.0.1, 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
@@ -22,6 +22,8 @@
2222
import io.asyncer.r2dbc.mysql.message.server.ServerMessage;
2323
import io.netty.buffer.ByteBufAllocator;
2424
import io.netty.channel.ChannelOption;
25+
import io.netty.util.internal.logging.InternalLogger;
26+
import io.netty.util.internal.logging.InternalLoggerFactory;
2527
import org.jetbrains.annotations.Nullable;
2628
import reactor.core.publisher.Flux;
2729
import reactor.core.publisher.Mono;
@@ -39,6 +41,7 @@
3941
* An abstraction that wraps the networking part of exchanging methods.
4042
*/
4143
public interface Client {
44+
InternalLogger logger = InternalLoggerFactory.getInstance(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)