File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed
main/java/com/microsoft/sqlserver/jdbc
test/java/com/microsoft/sqlserver/jdbc/connection Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
14
14
- Clear prepared statement handle before reconnect [ #2422 ] ( https://github.com/microsoft/mssql-jdbc/pull/2422 )
15
15
- RPC calls for CallableStatements will be executed directly [ #2427 ] ( https://github.com/microsoft/mssql-jdbc/pull/2427 )
16
16
- Corrected authentication token object to accept expiration in milliseconds [ #2428 ] ( https://github.com/microsoft/mssql-jdbc/pull/2428 )
17
+ - SocketTimeout should be unbounded by loginTimeout after a successful connection open [ #2431 ] ( https://github.com/microsoft/mssql-jdbc/pull/2431 )
17
18
18
19
## [ 12.6.1] Hotfix & Stable Release
19
20
### Fixed issues
Original file line number Diff line number Diff line change @@ -2366,6 +2366,10 @@ final int getNetworkTimeout() throws IOException {
2366
2366
final void setNetworkTimeout (int timeout ) throws IOException {
2367
2367
tcpSocket .setSoTimeout (timeout );
2368
2368
}
2369
+
2370
+ void resetTcpSocketTimeout () throws SocketException {
2371
+ this .tcpSocket .setSoTimeout (con .getSocketTimeoutMilliseconds ());
2372
+ }
2369
2373
}
2370
2374
2371
2375
Original file line number Diff line number Diff line change @@ -3225,9 +3225,15 @@ else if (0 == requestedPacketSize)
3225
3225
3226
3226
state = State .OPENED ;
3227
3227
3228
+ // Socket timeout is bounded by loginTimeout during the login phase.
3229
+ // Reset socket timeout back to the original value.
3230
+ tdsChannel .resetTcpSocketTimeout ();
3231
+
3228
3232
if (connectionlogger .isLoggable (Level .FINER )) {
3229
3233
connectionlogger .finer (toString () + " End of connect" );
3230
3234
}
3235
+ } catch (SocketException e ) {
3236
+ throw new SQLServerException (e .getMessage (), null );
3231
3237
} finally {
3232
3238
// once we exit the connect function, the connection can be only in one of two
3233
3239
// states, Opened or Closed(if an exception occurred)
Original file line number Diff line number Diff line change @@ -281,6 +281,18 @@ public void testConnectRetryTimeout() {
281
281
"total time: " + totalTime + " interval: " + TimeUnit .SECONDS .toMillis (interval ));
282
282
}
283
283
284
+ @ Test
285
+ public void testSocketTimeoutBoundedByLoginTimeoutReset () throws Exception {
286
+ try (Connection con = PrepUtil .getConnection (connectionString + ";socketTimeout=90000;loginTimeout=10;" );
287
+ Statement stmt = con .createStatement ()) {
288
+ // Login timeout (10s) is less than the 15s sec WAITFOR DELAY. Upon a login attempt, socketTimeout should be bounded
289
+ // by loginTimeout. After a successful login, when executing a query, socketTimeout should be reset to the
290
+ // original 90000ms timeout. The statement below should successfully execute as socketTimeout should not be bounded
291
+ // by loginTimeout, otherwise the test fails with a socket read timeout error.
292
+ stmt .execute ("WAITFOR DELAY '00:00:15';" );
293
+ }
294
+ }
295
+
284
296
// Test for detecting Azure server for connection retries
285
297
@ Test
286
298
public void testAzureEndpointRetry () {
You can’t perform that action at this time.
0 commit comments