Skip to content

Commit

Permalink
Remove deprecated socket timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
mirromutth committed Feb 7, 2024
1 parent 8eedb75 commit aa5e215
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 69 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
.option(DATABASE, "r2dbc") // optional, default null, null means not specifying the database
.option(Option.valueOf("createDatabaseIfNotExist"), true) // optional, default false, create database if not exist (since 1.0.6 / 0.9.7)
.option(CONNECT_TIMEOUT, Duration.ofSeconds(3)) // optional, default null, null means no timeout
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4)) // deprecated since 1.0.1, because it has no effect and serves no purpose.
.option(SSL, true) // optional, default sslMode is "preferred", it will be ignore if sslMode is set
.option(Option.valueOf("sslMode"), "verify_identity") // optional, default "preferred"
.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
Expand Down Expand Up @@ -179,7 +178,6 @@ MySqlConnectionConfiguration configuration = MySqlConnectionConfiguration.builde
.createDatabaseIfNotExist(true) // optional, default false, create database if not exist (since 1.0.6 / 0.9.7)
.serverZoneId(ZoneId.of("Continent/City")) // optional, default null, null means query server time zone when connection init
.connectTimeout(Duration.ofSeconds(3)) // optional, default null, null means no timeout
.socketTimeout(Duration.ofSeconds(4)) // deprecated since 1.0.1, because it has no effect and serves no purpose.
.sslMode(SslMode.VERIFY_IDENTITY) // optional, default SslMode.PREFERRED
.sslCa("/path/to/mysql/ca.pem") // required when sslMode is VERIFY_CA or VERIFY_IDENTITY, default null, null means has no server CA cert
.sslCert("/path/to/mysql/client-cert.pem") // optional, default has no client SSL certificate
Expand Down Expand Up @@ -229,7 +227,6 @@ Mono<Connection> connectionMono = Mono.from(connectionFactory.create());
| database | A valid MySQL database name | Optional, default does not initialize database | Database used by the MySQL connection |
| createDatabaseIfNotExist | `true` or `false` | Optional, default `false` | Create database if not exist |
| connectTimeout | A `Duration` which must be positive duration | Optional, default has no timeout | TCP connect timeout |
| socketTimeout | A `Duration` which must be positive duration | Deprecated since 1.0.1 | TCP socket timeout |
| serverZoneId | An id of `ZoneId` | Optional, default query time zone when connection init | Server time zone id |
| tcpKeepAlive | `true` or `false` | Optional, default disabled | Controls TCP KeepAlive |
| tcpNoDelay | `true` or `false` | Optional, default disabled | Controls TCP NoDelay |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ public final class MySqlConnectionConfiguration {
@Nullable
private final Duration connectTimeout;

@Nullable
private final Duration socketTimeout;

@Nullable
private final ZoneId serverZoneId;

Expand Down Expand Up @@ -108,7 +105,7 @@ public final class MySqlConnectionConfiguration {
private MySqlConnectionConfiguration(
boolean isHost, String domain, int port, MySqlSslConfiguration ssl,
boolean tcpKeepAlive, boolean tcpNoDelay, @Nullable Duration connectTimeout,
@Nullable Duration socketTimeout, ZeroDateOption zeroDateOption, @Nullable ZoneId serverZoneId,
ZeroDateOption zeroDateOption, @Nullable ZoneId serverZoneId,
String user, @Nullable CharSequence password, @Nullable String database,
boolean createDatabaseIfNotExist, @Nullable Predicate<String> preferPrepareStatement,
@Nullable Path loadLocalInfilePath, int localInfileBufferSize,
Expand All @@ -121,7 +118,6 @@ private MySqlConnectionConfiguration(
this.tcpKeepAlive = tcpKeepAlive;
this.tcpNoDelay = tcpNoDelay;
this.connectTimeout = connectTimeout;
this.socketTimeout = socketTimeout;
this.ssl = ssl;
this.serverZoneId = serverZoneId;
this.zeroDateOption = requireNonNull(zeroDateOption, "zeroDateOption must not be null");
Expand Down Expand Up @@ -164,16 +160,6 @@ Duration getConnectTimeout() {
return connectTimeout;
}

/**
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and serves no purpose.
* Please remove any references to this option from your code, as it will be removed in a future release.
*/
@Nullable
@Deprecated
Duration getSocketTimeout() {
return socketTimeout;
}

MySqlSslConfiguration getSsl() {
return ssl;
}
Expand Down Expand Up @@ -259,7 +245,6 @@ public boolean equals(Object o) {
tcpKeepAlive == that.tcpKeepAlive &&
tcpNoDelay == that.tcpNoDelay &&
Objects.equals(connectTimeout, that.connectTimeout) &&
Objects.equals(socketTimeout, that.socketTimeout) &&
Objects.equals(serverZoneId, that.serverZoneId) &&
zeroDateOption == that.zeroDateOption &&
user.equals(that.user) &&
Expand All @@ -278,7 +263,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
return Objects.hash(isHost, domain, port, ssl, tcpKeepAlive, tcpNoDelay, connectTimeout,
socketTimeout, serverZoneId, zeroDateOption, user, password, database, createDatabaseIfNotExist,
serverZoneId, zeroDateOption, user, password, database, createDatabaseIfNotExist,
preferPrepareStatement, loadLocalInfilePath, localInfileBufferSize, queryCacheSize,
prepareCacheSize, extensions, passwordPublisher);
}
Expand All @@ -287,8 +272,8 @@ public int hashCode() {
public String toString() {
if (isHost) {
return "MySqlConnectionConfiguration{host='" + domain + "', port=" + port + ", ssl=" + ssl +
", tcpNoDelay=" + tcpNoDelay + ", tcpKeepAlive=" + tcpKeepAlive + ", connectTimeout=" +
connectTimeout + ", socketTimeout=" + socketTimeout + ", serverZoneId=" + serverZoneId +
", tcpNoDelay=" + tcpNoDelay + ", tcpKeepAlive=" + tcpKeepAlive +
", connectTimeout=" + connectTimeout + ", serverZoneId=" + serverZoneId +
", zeroDateOption=" + zeroDateOption + ", user='" + user + "', password=" + password +
", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
", preferPrepareStatement=" + preferPrepareStatement +
Expand All @@ -298,8 +283,8 @@ public String toString() {
", extensions=" + extensions + ", passwordPublisher=" + passwordPublisher + '}';
}

return "MySqlConnectionConfiguration{unixSocket='" + domain + "', connectTimeout=" +
connectTimeout + ", socketTimeout=" + socketTimeout + ", serverZoneId=" + serverZoneId +
return "MySqlConnectionConfiguration{unixSocket='" + domain +
"', connectTimeout=" + connectTimeout + ", serverZoneId=" + serverZoneId +
", zeroDateOption=" + zeroDateOption + ", user='" + user + "', password=" + password +
", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
", preferPrepareStatement=" + preferPrepareStatement +
Expand Down Expand Up @@ -332,9 +317,6 @@ public static final class Builder {
@Nullable
private Duration connectTimeout;

@Nullable
private Duration socketTimeout;

private String user;

private ZeroDateOption zeroDateOption = ZeroDateOption.USE_NULL;
Expand Down Expand Up @@ -410,7 +392,7 @@ public MySqlConnectionConfiguration build() {
MySqlSslConfiguration ssl = MySqlSslConfiguration.create(sslMode, tlsVersion, sslHostnameVerifier,
sslCa, sslKey, sslKeyPassword, sslCert, sslContextBuilderCustomizer);
return new MySqlConnectionConfiguration(isHost, domain, port, ssl, tcpKeepAlive, tcpNoDelay,
connectTimeout, socketTimeout, zeroDateOption, serverZoneId, user, password, database,
connectTimeout, zeroDateOption, serverZoneId, user, password, database,
createDatabaseIfNotExist, preferPrepareStatement, loadLocalInfilePath,
localInfileBufferSize, queryCacheSize, prepareCacheSize,
Extensions.from(extensions, autodetectExtensions), passwordPublisher);
Expand Down Expand Up @@ -510,22 +492,6 @@ public Builder connectTimeout(@Nullable Duration connectTimeout) {
return this;
}

/**
* Configure the socket timeout, only for compatibility with {@code socketTimeout} property in the
* JDBC driver. In fact, {@code SO_TIMEOUT} has effect only for OIO socket transport. Default no
* timeout.
*
* @param socketTimeout the socket timeout, or {@code null} if has no timeout.
* @return this {@link Builder}.
* @since 0.8.6
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and
* serves no purpose.
*/
public Builder socketTimeout(@Nullable Duration socketTimeout) {
this.socketTimeout = socketTimeout;
return this;
}

/**
* Set the user for login the database.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static Mono<MySqlConnection> getMySqlConnection(
final int prepareCacheSize,
@Nullable final CharSequence password) {
return Client.connect(ssl, address, configuration.isTcpKeepAlive(), configuration.isTcpNoDelay(),
context, configuration.getConnectTimeout(), configuration.getSocketTimeout())
context, configuration.getConnectTimeout())
.flatMap(client -> {
// Lazy init database after handshake/login
String db = createDbIfNotExist ? "" : database;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
public static final Option<Function<SslContextBuilder, SslContextBuilder>>
SSL_CONTEXT_BUILDER_CUSTOMIZER = Option.valueOf("sslContextBuilderCustomizer");

/**
* TCP socket timeout
*
* @since 0.8.3
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and serves no purpose.
* Please remove any references to this option from your code, as it will be removed in a future release.
*/
@Deprecated
public static final Option<Duration> SOCKET_TIMEOUT = Option.valueOf("socketTimeout");

/**
* Enable/Disable TCP KeepAlive.
*
Expand Down Expand Up @@ -279,8 +269,6 @@ static MySqlConnectionConfiguration setup(ConnectionFactoryOptions options) {
.to(builder::autodetectExtensions);
mapper.optional(CONNECT_TIMEOUT).as(Duration.class, Duration::parse)
.to(builder::connectTimeout);
mapper.optional(SOCKET_TIMEOUT).as(Duration.class, Duration::parse)
.to(builder::socketTimeout);
mapper.optional(DATABASE).asString()
.to(builder::database);
mapper.optional(CREATE_DATABASE_IF_NOT_EXIST).asBoolean()
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/io/asyncer/r2dbc/mysql/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,12 @@ public interface Client {
* @param tcpNoDelay if enable the {@link ChannelOption#TCP_NODELAY}
* @param context the connection context
* @param connectTimeout connect timeout, or {@code null} if it has no timeout
* @param socketTimeout socket timeout, or {@code null} if it has no timeout
* @return A {@link Mono} that will emit a connected {@link Client}.
* @throws IllegalArgumentException if {@code ssl}, {@code address} or {@code context} is {@code null}.
* @throws ArithmeticException if {@code connectTimeout} or {@code socketTimeout} milliseconds
* overflow as an int
* @throws ArithmeticException if {@code connectTimeout} milliseconds overflow as an int
*/
static Mono<Client> connect(MySqlSslConfiguration ssl, SocketAddress address, boolean tcpKeepAlive,
boolean tcpNoDelay, ConnectionContext context, @Nullable Duration connectTimeout,
@Nullable Duration socketTimeout) {
boolean tcpNoDelay, ConnectionContext context, @Nullable Duration connectTimeout) {
requireNonNull(ssl, "ssl must not be null");
requireNonNull(address, "address must not be null");
requireNonNull(context, "context must not be null");
Expand All @@ -136,10 +133,6 @@ static Mono<Client> connect(MySqlSslConfiguration ssl, SocketAddress address, bo
Math.toIntExact(connectTimeout.toMillis()));
}

if (socketTimeout != null) {
logger.warn("Socket timeout is not supported by the underlying connection and will be ignored.");
}

if (address instanceof InetSocketAddress) {
tcpClient = tcpClient.option(ChannelOption.SO_KEEPALIVE, tcpKeepAlive);
tcpClient = tcpClient.option(ChannelOption.TCP_NODELAY, tcpNoDelay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ private static MySqlConnectionConfiguration filledUp() {
.tcpKeepAlive(true)
.tcpNoDelay(true)
.connectTimeout(Duration.ofSeconds(3))
.socketTimeout(Duration.ofSeconds(4))
.sslMode(SslMode.VERIFY_IDENTITY)
.sslCa(SSL_CA)
.sslCert("/path/to/mysql/client-cert.pem")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ void validProgrammaticHost() {
.option(PASSWORD, "123456")
.option(SSL, true)
.option(Option.valueOf(CONNECT_TIMEOUT.name()), Duration.ofSeconds(3).toString())
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4).toString())
.option(DATABASE, "r2dbc")
.option(Option.valueOf("serverZoneId"), "Asia/Tokyo")
.option(Option.valueOf("useServerPrepareStatement"), AllTruePredicate.class.getName())
Expand All @@ -156,7 +155,6 @@ void validProgrammaticHost() {
assertThat(configuration.getUser()).isEqualTo("root");
assertThat(configuration.getPassword()).isEqualTo("123456");
assertThat(configuration.getConnectTimeout()).isEqualTo(Duration.ofSeconds(3));
assertThat(configuration.getSocketTimeout()).isEqualTo(Duration.ofSeconds(4));
assertThat(configuration.getDatabase()).isEqualTo("r2dbc");
assertThat(configuration.getZeroDateOption()).isEqualTo(ZeroDateOption.USE_ROUND);
assertThat(configuration.isTcpKeepAlive()).isTrue();
Expand Down

0 comments on commit aa5e215

Please sign in to comment.