Skip to content

Commit aa5e215

Browse files
committed
Remove deprecated socket timeout option
1 parent 8eedb75 commit aa5e215

File tree

7 files changed

+10
-69
lines changed

7 files changed

+10
-69
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
129129
.option(DATABASE, "r2dbc") // optional, default null, null means not specifying the database
130130
.option(Option.valueOf("createDatabaseIfNotExist"), true) // optional, default false, create database if not exist (since 1.0.6 / 0.9.7)
131131
.option(CONNECT_TIMEOUT, Duration.ofSeconds(3)) // optional, default null, null means no timeout
132-
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4)) // deprecated since 1.0.1, because it has no effect and serves no purpose.
133132
.option(SSL, true) // optional, default sslMode is "preferred", it will be ignore if sslMode is set
134133
.option(Option.valueOf("sslMode"), "verify_identity") // optional, default "preferred"
135134
.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
@@ -179,7 +178,6 @@ MySqlConnectionConfiguration configuration = MySqlConnectionConfiguration.builde
179178
.createDatabaseIfNotExist(true) // optional, default false, create database if not exist (since 1.0.6 / 0.9.7)
180179
.serverZoneId(ZoneId.of("Continent/City")) // optional, default null, null means query server time zone when connection init
181180
.connectTimeout(Duration.ofSeconds(3)) // optional, default null, null means no timeout
182-
.socketTimeout(Duration.ofSeconds(4)) // deprecated since 1.0.1, because it has no effect and serves no purpose.
183181
.sslMode(SslMode.VERIFY_IDENTITY) // optional, default SslMode.PREFERRED
184182
.sslCa("/path/to/mysql/ca.pem") // required when sslMode is VERIFY_CA or VERIFY_IDENTITY, default null, null means has no server CA cert
185183
.sslCert("/path/to/mysql/client-cert.pem") // optional, default has no client SSL certificate
@@ -229,7 +227,6 @@ Mono<Connection> connectionMono = Mono.from(connectionFactory.create());
229227
| database | A valid MySQL database name | Optional, default does not initialize database | Database used by the MySQL connection |
230228
| createDatabaseIfNotExist | `true` or `false` | Optional, default `false` | Create database if not exist |
231229
| connectTimeout | A `Duration` which must be positive duration | Optional, default has no timeout | TCP connect timeout |
232-
| socketTimeout | A `Duration` which must be positive duration | Deprecated since 1.0.1 | TCP socket timeout |
233230
| serverZoneId | An id of `ZoneId` | Optional, default query time zone when connection init | Server time zone id |
234231
| tcpKeepAlive | `true` or `false` | Optional, default disabled | Controls TCP KeepAlive |
235232
| tcpNoDelay | `true` or `false` | Optional, default disabled | Controls TCP NoDelay |

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

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ public final class MySqlConnectionConfiguration {
7171
@Nullable
7272
private final Duration connectTimeout;
7373

74-
@Nullable
75-
private final Duration socketTimeout;
76-
7774
@Nullable
7875
private final ZoneId serverZoneId;
7976

@@ -108,7 +105,7 @@ public final class MySqlConnectionConfiguration {
108105
private MySqlConnectionConfiguration(
109106
boolean isHost, String domain, int port, MySqlSslConfiguration ssl,
110107
boolean tcpKeepAlive, boolean tcpNoDelay, @Nullable Duration connectTimeout,
111-
@Nullable Duration socketTimeout, ZeroDateOption zeroDateOption, @Nullable ZoneId serverZoneId,
108+
ZeroDateOption zeroDateOption, @Nullable ZoneId serverZoneId,
112109
String user, @Nullable CharSequence password, @Nullable String database,
113110
boolean createDatabaseIfNotExist, @Nullable Predicate<String> preferPrepareStatement,
114111
@Nullable Path loadLocalInfilePath, int localInfileBufferSize,
@@ -121,7 +118,6 @@ private MySqlConnectionConfiguration(
121118
this.tcpKeepAlive = tcpKeepAlive;
122119
this.tcpNoDelay = tcpNoDelay;
123120
this.connectTimeout = connectTimeout;
124-
this.socketTimeout = socketTimeout;
125121
this.ssl = ssl;
126122
this.serverZoneId = serverZoneId;
127123
this.zeroDateOption = requireNonNull(zeroDateOption, "zeroDateOption must not be null");
@@ -164,16 +160,6 @@ Duration getConnectTimeout() {
164160
return connectTimeout;
165161
}
166162

167-
/**
168-
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and serves no purpose.
169-
* Please remove any references to this option from your code, as it will be removed in a future release.
170-
*/
171-
@Nullable
172-
@Deprecated
173-
Duration getSocketTimeout() {
174-
return socketTimeout;
175-
}
176-
177163
MySqlSslConfiguration getSsl() {
178164
return ssl;
179165
}
@@ -259,7 +245,6 @@ public boolean equals(Object o) {
259245
tcpKeepAlive == that.tcpKeepAlive &&
260246
tcpNoDelay == that.tcpNoDelay &&
261247
Objects.equals(connectTimeout, that.connectTimeout) &&
262-
Objects.equals(socketTimeout, that.socketTimeout) &&
263248
Objects.equals(serverZoneId, that.serverZoneId) &&
264249
zeroDateOption == that.zeroDateOption &&
265250
user.equals(that.user) &&
@@ -278,7 +263,7 @@ public boolean equals(Object o) {
278263
@Override
279264
public int hashCode() {
280265
return Objects.hash(isHost, domain, port, ssl, tcpKeepAlive, tcpNoDelay, connectTimeout,
281-
socketTimeout, serverZoneId, zeroDateOption, user, password, database, createDatabaseIfNotExist,
266+
serverZoneId, zeroDateOption, user, password, database, createDatabaseIfNotExist,
282267
preferPrepareStatement, loadLocalInfilePath, localInfileBufferSize, queryCacheSize,
283268
prepareCacheSize, extensions, passwordPublisher);
284269
}
@@ -287,8 +272,8 @@ public int hashCode() {
287272
public String toString() {
288273
if (isHost) {
289274
return "MySqlConnectionConfiguration{host='" + domain + "', port=" + port + ", ssl=" + ssl +
290-
", tcpNoDelay=" + tcpNoDelay + ", tcpKeepAlive=" + tcpKeepAlive + ", connectTimeout=" +
291-
connectTimeout + ", socketTimeout=" + socketTimeout + ", serverZoneId=" + serverZoneId +
275+
", tcpNoDelay=" + tcpNoDelay + ", tcpKeepAlive=" + tcpKeepAlive +
276+
", connectTimeout=" + connectTimeout + ", serverZoneId=" + serverZoneId +
292277
", zeroDateOption=" + zeroDateOption + ", user='" + user + "', password=" + password +
293278
", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
294279
", preferPrepareStatement=" + preferPrepareStatement +
@@ -298,8 +283,8 @@ public String toString() {
298283
", extensions=" + extensions + ", passwordPublisher=" + passwordPublisher + '}';
299284
}
300285

301-
return "MySqlConnectionConfiguration{unixSocket='" + domain + "', connectTimeout=" +
302-
connectTimeout + ", socketTimeout=" + socketTimeout + ", serverZoneId=" + serverZoneId +
286+
return "MySqlConnectionConfiguration{unixSocket='" + domain +
287+
"', connectTimeout=" + connectTimeout + ", serverZoneId=" + serverZoneId +
303288
", zeroDateOption=" + zeroDateOption + ", user='" + user + "', password=" + password +
304289
", database='" + database + "', createDatabaseIfNotExist=" + createDatabaseIfNotExist +
305290
", preferPrepareStatement=" + preferPrepareStatement +
@@ -332,9 +317,6 @@ public static final class Builder {
332317
@Nullable
333318
private Duration connectTimeout;
334319

335-
@Nullable
336-
private Duration socketTimeout;
337-
338320
private String user;
339321

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

513-
/**
514-
* Configure the socket timeout, only for compatibility with {@code socketTimeout} property in the
515-
* JDBC driver. In fact, {@code SO_TIMEOUT} has effect only for OIO socket transport. Default no
516-
* timeout.
517-
*
518-
* @param socketTimeout the socket timeout, or {@code null} if has no timeout.
519-
* @return this {@link Builder}.
520-
* @since 0.8.6
521-
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and
522-
* serves no purpose.
523-
*/
524-
public Builder socketTimeout(@Nullable Duration socketTimeout) {
525-
this.socketTimeout = socketTimeout;
526-
return this;
527-
}
528-
529495
/**
530496
* Set the user for login the database.
531497
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private static Mono<MySqlConnection> getMySqlConnection(
138138
final int prepareCacheSize,
139139
@Nullable final CharSequence password) {
140140
return Client.connect(ssl, address, configuration.isTcpKeepAlive(), configuration.isTcpNoDelay(),
141-
context, configuration.getConnectTimeout(), configuration.getSocketTimeout())
141+
context, configuration.getConnectTimeout())
142142
.flatMap(client -> {
143143
// Lazy init database after handshake/login
144144
String db = createDbIfNotExist ? "" : database;

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,6 @@ public final class MySqlConnectionFactoryProvider implements ConnectionFactoryPr
138138
public static final Option<Function<SslContextBuilder, SslContextBuilder>>
139139
SSL_CONTEXT_BUILDER_CUSTOMIZER = Option.valueOf("sslContextBuilderCustomizer");
140140

141-
/**
142-
* TCP socket timeout
143-
*
144-
* @since 0.8.3
145-
* @deprecated This option has been deprecated as of version 1.0.1, because it has no effect and serves no purpose.
146-
* Please remove any references to this option from your code, as it will be removed in a future release.
147-
*/
148-
@Deprecated
149-
public static final Option<Duration> SOCKET_TIMEOUT = Option.valueOf("socketTimeout");
150-
151141
/**
152142
* Enable/Disable TCP KeepAlive.
153143
*
@@ -279,8 +269,6 @@ static MySqlConnectionConfiguration setup(ConnectionFactoryOptions options) {
279269
.to(builder::autodetectExtensions);
280270
mapper.optional(CONNECT_TIMEOUT).as(Duration.class, Duration::parse)
281271
.to(builder::connectTimeout);
282-
mapper.optional(SOCKET_TIMEOUT).as(Duration.class, Duration::parse)
283-
.to(builder::socketTimeout);
284272
mapper.optional(DATABASE).asString()
285273
.to(builder::database);
286274
mapper.optional(CREATE_DATABASE_IF_NOT_EXIST).asBoolean()

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,12 @@ public interface Client {
116116
* @param tcpNoDelay if enable the {@link ChannelOption#TCP_NODELAY}
117117
* @param context the connection context
118118
* @param connectTimeout connect timeout, or {@code null} if it has no timeout
119-
* @param socketTimeout socket timeout, or {@code null} if it has no timeout
120119
* @return A {@link Mono} that will emit a connected {@link Client}.
121120
* @throws IllegalArgumentException if {@code ssl}, {@code address} or {@code context} is {@code null}.
122-
* @throws ArithmeticException if {@code connectTimeout} or {@code socketTimeout} milliseconds
123-
* overflow as an int
121+
* @throws ArithmeticException if {@code connectTimeout} milliseconds overflow as an int
124122
*/
125123
static Mono<Client> connect(MySqlSslConfiguration ssl, SocketAddress address, boolean tcpKeepAlive,
126-
boolean tcpNoDelay, ConnectionContext context, @Nullable Duration connectTimeout,
127-
@Nullable Duration socketTimeout) {
124+
boolean tcpNoDelay, ConnectionContext context, @Nullable Duration connectTimeout) {
128125
requireNonNull(ssl, "ssl must not be null");
129126
requireNonNull(address, "address must not be null");
130127
requireNonNull(context, "context must not be null");
@@ -136,10 +133,6 @@ static Mono<Client> connect(MySqlSslConfiguration ssl, SocketAddress address, bo
136133
Math.toIntExact(connectTimeout.toMillis()));
137134
}
138135

139-
if (socketTimeout != null) {
140-
logger.warn("Socket timeout is not supported by the underlying connection and will be ignored.");
141-
}
142-
143136
if (address instanceof InetSocketAddress) {
144137
tcpClient = tcpClient.option(ChannelOption.SO_KEEPALIVE, tcpKeepAlive);
145138
tcpClient = tcpClient.option(ChannelOption.TCP_NODELAY, tcpNoDelay);

src/test/java/io/asyncer/r2dbc/mysql/MySqlConnectionConfigurationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ private static MySqlConnectionConfiguration filledUp() {
234234
.tcpKeepAlive(true)
235235
.tcpNoDelay(true)
236236
.connectTimeout(Duration.ofSeconds(3))
237-
.socketTimeout(Duration.ofSeconds(4))
238237
.sslMode(SslMode.VERIFY_IDENTITY)
239238
.sslCa(SSL_CA)
240239
.sslCert("/path/to/mysql/client-cert.pem")

src/test/java/io/asyncer/r2dbc/mysql/MySqlConnectionFactoryProviderTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ void validProgrammaticHost() {
129129
.option(PASSWORD, "123456")
130130
.option(SSL, true)
131131
.option(Option.valueOf(CONNECT_TIMEOUT.name()), Duration.ofSeconds(3).toString())
132-
.option(Option.valueOf("socketTimeout"), Duration.ofSeconds(4).toString())
133132
.option(DATABASE, "r2dbc")
134133
.option(Option.valueOf("serverZoneId"), "Asia/Tokyo")
135134
.option(Option.valueOf("useServerPrepareStatement"), AllTruePredicate.class.getName())
@@ -156,7 +155,6 @@ void validProgrammaticHost() {
156155
assertThat(configuration.getUser()).isEqualTo("root");
157156
assertThat(configuration.getPassword()).isEqualTo("123456");
158157
assertThat(configuration.getConnectTimeout()).isEqualTo(Duration.ofSeconds(3));
159-
assertThat(configuration.getSocketTimeout()).isEqualTo(Duration.ofSeconds(4));
160158
assertThat(configuration.getDatabase()).isEqualTo("r2dbc");
161159
assertThat(configuration.getZeroDateOption()).isEqualTo(ZeroDateOption.USE_ROUND);
162160
assertThat(configuration.isTcpKeepAlive()).isTrue();

0 commit comments

Comments
 (0)