Skip to content

Commit 3253ab1

Browse files
author
ehennum
committed
an expired session id is effectively a new session id #1170
1 parent 008a48c commit 3253ab1

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/dataservices/impl/IOEndpointImpl.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ abstract class IOEndpointImpl implements IOEndpoint {
4141
private static Logger logger = LoggerFactory.getLogger(IOEndpointImpl.class);
4242

4343
final static int DEFAULT_BATCH_SIZE = 100;
44-
final static int DEFAULT_SESSION_TIMEOUT = 3600;
45-
46-
private static Duration sessionDuration = null;
4744

4845
private DatabaseClient client;
4946
private IOCallerImpl caller;
@@ -55,25 +52,6 @@ public IOEndpointImpl(DatabaseClient client, IOCallerImpl caller) {
5552
throw new IllegalArgumentException("null caller");
5653
this.client = client;
5754
this.caller = caller;
58-
59-
// the session configuration shouldn't change, so establish the session duration once
60-
if (sessionDuration == null && allowsSession()) {
61-
int sessionTimeout = DEFAULT_SESSION_TIMEOUT;
62-
63-
try {
64-
JsonNode config = ((DatabaseClientImpl) client).getServices()
65-
.getResource(null, "internal/config", null, null, new JacksonHandle())
66-
.get();
67-
JsonNode sessionTimeoutProp = config.get("sessionTimeout");
68-
if (sessionTimeoutProp != null && sessionTimeoutProp.isNumber())
69-
sessionTimeout = sessionTimeoutProp.asInt(DEFAULT_SESSION_TIMEOUT);
70-
} catch (Exception e) {
71-
logger.warn("could not get session timeout", e);
72-
}
73-
74-
// size the session duration to half of the configured session time
75-
sessionDuration = Duration.ofSeconds(sessionTimeout / 2);
76-
}
7755
}
7856

7957
int initBatchSize(IOCallerImpl caller) {
@@ -86,10 +64,6 @@ int initBatchSize(IOCallerImpl caller) {
8664
return DEFAULT_BATCH_SIZE;
8765
}
8866

89-
private static Duration getSessionDuration() {
90-
return sessionDuration;
91-
}
92-
9367
DatabaseClient getClient() {
9468
return this.client;
9569
}
@@ -145,7 +119,6 @@ enum WorkPhase {
145119
private byte[] endpointState;
146120
private byte[] workUnit;
147121
private SessionState session;
148-
private Instant sessionRefreshAfter;
149122

150123
private long callCount = 0;
151124

@@ -225,9 +198,10 @@ SessionState getSession() {
225198
if (!allowsSession())
226199
return null;
227200

228-
if (session == null || sessionRefreshAfter.isBefore(Instant.now())) {
201+
if (session == null) {
202+
// no need to refresh the session id preemptively before timeout
203+
// because a timed-out session id is merely a new session id
229204
session = getEndpoint().getCaller().newSessionState();
230-
sessionRefreshAfter = Instant.now().plus(endpoint.getSessionDuration());
231205
}
232206
return session;
233207
}

0 commit comments

Comments
 (0)