Skip to content

Commit c8d503d

Browse files
authored
Preparing for 5.4.11 release
Changed internal IAM logic to close channel on SSL errors before doing internal retry
1 parent 2ea163e commit c8d503d

File tree

10 files changed

+60
-16
lines changed

10 files changed

+60
-16
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](http://keepachangelog.com/).
44

5+
## [5.4.11] 2023-06-06
6+
7+
### Fixed
8+
- Changed internal IAM logic to close channel on SSL errors before doing internal retry
9+
510
## [5.4.10] 2023-04-25
611

712
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ project. The version changes with each release.
3737
<dependency>
3838
<groupId>com.oracle.nosql.sdk</groupId>
3939
<artifactId>nosqldriver</artifactId>
40-
<version>5.4.10</version>
40+
<version>5.4.11</version>
4141
</dependency>
4242
```
4343

driver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<groupId>com.oracle.nosql.sdk</groupId>
3131
<artifactId>nosqldriver</artifactId>
32-
<version>5.4.10</version>
32+
<version>5.4.11</version>
3333
<packaging>jar</packaging>
3434

3535
<organization>

driver/src/main/java/oracle/nosql/driver/http/Client.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,17 @@ public Result execute(Request kvRequest) {
923923

924924
kvRequest.setRateLimitDelayedMs(rateDelayedMs);
925925
statsControl.observeError(kvRequest);
926+
/*
927+
* If the request timed out in a single iteration, and the
928+
* timeout was fairly long, and there was no delay due to
929+
* rate limiting, reset the session cookie so the next request
930+
* may use a different server.
931+
*/
932+
if (timeoutMs == thisIterationTimeoutMs &&
933+
timeoutMs >= 2000 &&
934+
rateDelayedMs == 0) {
935+
setSessionCookieValue(null);
936+
}
926937
throw new RequestTimeoutException(timeoutMs,
927938
requestClass + " timed out:" +
928939
(requestId.isEmpty() ? "" : " requestId=" + requestId) +

driver/src/main/java/oracle/nosql/driver/httpclient/ResponseHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.CountDownLatch;
1616
import java.util.concurrent.TimeUnit;
1717
import java.util.logging.Logger;
18+
import javax.net.ssl.SSLException;
1819

1920
import io.netty.buffer.ByteBuf;
2021
import io.netty.channel.Channel;
@@ -90,6 +91,10 @@ public void handleException(String msg, Throwable th) {
9091

9192
synchronized(this) {
9293
this.cause = th;
94+
if (th instanceof SSLException) {
95+
/* disconnect channel to re-create channel and engine */
96+
channel.disconnect();
97+
}
9398
latch.countDown();
9499
}
95100
logFine(logger, msg + ", cause: " + th);

driver/src/main/java/oracle/nosql/driver/iam/InstancePrincipalsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static class InstancePrincipalsProviderBuilder {
129129
"169.254.169.254";
130130

131131
/* The default value for HTTP request timeouts in milliseconds */
132-
private static final int DEFAULT_TIMEOUT_MS = 120_000;
132+
private static final int DEFAULT_TIMEOUT_MS = 5_000;
133133

134134
/* The default purpose value in federation requests against IAM */
135135
private static final String DEFAULT_PURPOSE = "DEFAULT";

driver/src/main/java/oracle/nosql/driver/iam/SignatureProvider.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -647,21 +647,33 @@ public static SignatureProvider createWithResourcePrincipal(Logger logger) {
647647
return provider;
648648
}
649649

650-
/*
650+
/**
651+
* Constructor for SignatureProvider given an
652+
* AuthenticationProfileProvider.
653+
* This is for advanced use only; use of the create* methods is preferred.
651654
* The SignatureProvider that generates and caches request signature using
652655
* key id and private key supplied by {@link AuthenticationProfileProvider}.
656+
*
657+
* @param provider The provider to use
653658
*/
654-
protected SignatureProvider(AuthenticationProfileProvider provider) {
659+
public SignatureProvider(AuthenticationProfileProvider provider) {
655660
this(provider, MAX_ENTRY_LIFE_TIME, DEFAULT_REFRESH_AHEAD);
656661
}
657662

658-
/*
663+
/**
664+
* Constructor for SignatureProvider given an
665+
* AuthenticationProfileProvider and refresh details.
666+
* This is for advanced use only; use of the create* methods is preferred.
659667
* The constructor that is able to set refresh time before signature
660-
* expire, currently this is hidden for simplicity.
668+
* expires.
669+
*
670+
* @param profileProvider The provider to use
671+
* @param durationSeconds amount of time to keep signature before refresh
672+
* @param refreshAheadMs how soon before expiry to start a new refresh
661673
*/
662-
protected SignatureProvider(AuthenticationProfileProvider profileProvider,
674+
public SignatureProvider(AuthenticationProfileProvider profileProvider,
663675
int durationSeconds,
664-
int refreshAhead) {
676+
int refreshAheadMs) {
665677
if (profileProvider instanceof RegionProvider) {
666678
this.region = ((RegionProvider) profileProvider).getRegion();
667679
}
@@ -675,7 +687,7 @@ protected SignatureProvider(AuthenticationProfileProvider profileProvider,
675687
MAX_ENTRY_LIFE_TIME + " seconds");
676688
}
677689

678-
this.refreshAheadMs = refreshAhead;
690+
this.refreshAheadMs = refreshAheadMs;
679691
long durationMS = durationSeconds * 1000;
680692
if (durationMS > refreshAheadMs) {
681693
this.refreshIntervalMs = durationMS - refreshAheadMs;

driver/src/main/java/oracle/nosql/driver/util/HttpRequestUtil.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.concurrent.ExecutionException;
2424
import java.util.concurrent.TimeoutException;
2525
import java.util.logging.Logger;
26+
import javax.net.ssl.SSLException;
2627

2728
import oracle.nosql.driver.RequestTimeoutException;
2829
import oracle.nosql.driver.httpclient.HttpClient;
@@ -42,7 +43,7 @@
4243
*/
4344
public class HttpRequestUtil {
4445
private static final Charset utf8 = Charset.forName("UTF-8");
45-
private static final int DEFAULT_DELAY_MS = 1000;
46+
private static final int DEFAULT_DELAY_MS = 200;
4647

4748
/**
4849
* Issue HTTP GET request using given HTTP client with retries and general
@@ -212,9 +213,10 @@ private static HttpResponse doRequest(HttpClient httpClient,
212213
logInfo(logger, "Client, doing retry: " + numRetries +
213214
(exception != null ? ", exception: " + exception : ""));
214215
}
216+
Channel channel = null;
215217
ResponseHandler responseHandler = null;
216218
try {
217-
final Channel channel = httpClient.getChannel(timeoutMs);
219+
channel = httpClient.getChannel(timeoutMs);
218220
responseHandler =
219221
new ResponseHandler(httpClient, logger, channel);
220222

@@ -267,8 +269,17 @@ private static HttpResponse doRequest(HttpClient httpClient,
267269
* disconnected. Retry.
268270
*/
269271
exception = ioe;
270-
delay();
271272
++numRetries;
273+
if (ioe instanceof SSLException) {
274+
/* disconnect the channel to force a new one */
275+
if (channel != null) {
276+
logFine(logger,
277+
"Client disconnecting channel due to: " + ioe);
278+
channel.disconnect();
279+
}
280+
} else {
281+
delay();
282+
}
272283
continue;
273284
} catch (InterruptedException ie) {
274285
throw new RuntimeException(

examples/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>com.oracle.nosql.sdk</groupId>
6-
<version>5.4.10</version>
6+
<version>5.4.11</version>
77
<artifactId>nosql-java-sdk-examples</artifactId>
88
<name>Oracle NoSQL Database Java Examples</name>
99
<description>Java examples for Oracle NoSQL Database</description>
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>com.oracle.nosql.sdk</groupId>
2727
<artifactId>nosqldriver</artifactId>
28-
<version>5.4.10</version>
28+
<version>5.4.11</version>
2929
</dependency>
3030
</dependencies>
3131

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.oracle.nosql.sdk</groupId>
88
<artifactId>nosql-java-sdk</artifactId>
9-
<version>5.4.10</version>
9+
<version>5.4.11</version>
1010
<packaging>pom</packaging>
1111
<name>Oracle NoSQL SDK</name>
1212
<description>

0 commit comments

Comments
 (0)