setSession() — netty Function Reference
Architecture documentation for the setSession() function in OpenSslClientSessionCache.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3464953c_f03e_be1f_7bcc_18c2f7cfc2aa["setSession()"] d994a42d_c2fd_7695_2456_467a8b045cb7["OpenSslClientSessionCache"] 3464953c_f03e_be1f_7bcc_18c2f7cfc2aa -->|defined in| d994a42d_c2fd_7695_2456_467a8b045cb7 style 3464953c_f03e_be1f_7bcc_18c2f7cfc2aa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java lines 72–136
@Override
boolean setSession(long ssl, OpenSslInternalSession session, String host, int port) {
HostPort hostPort = keyFor(host, port);
if (hostPort == null) {
return false;
}
NativeSslSession nativeSslSession = null;
final boolean reused;
boolean singleUsed = false;
synchronized (this) {
Set<NativeSslSession> sessionsForHost = sessions.get(hostPort);
if (sessionsForHost == null) {
return false;
}
if (sessionsForHost.isEmpty()) {
sessions.remove(hostPort);
// There is no session that we can use.
return false;
}
List<NativeSslSession> toBeRemoved = null;
// Loop through all the sessions that might be usable and check if we can use one of these.
for (NativeSslSession sslSession : sessionsForHost) {
if (sslSession.isValid()) {
nativeSslSession = sslSession;
break;
} else {
if (toBeRemoved == null) {
toBeRemoved = new ArrayList<>(2);
}
toBeRemoved.add(sslSession);
}
}
// Remove everything that is not valid anymore
if (toBeRemoved != null) {
for (NativeSslSession sslSession : toBeRemoved) {
removeSessionWithId(sslSession.sessionId());
}
}
if (nativeSslSession == null) {
// Couldn't find a valid session that could be used.
return false;
}
// Try to set the session, if true is returned OpenSSL incremented the reference count
// of the underlying SSL_SESSION*.
reused = SSL.setSession(ssl, nativeSslSession.session());
if (reused) {
singleUsed = nativeSslSession.shouldBeSingleUse();
}
}
if (reused) {
if (singleUsed) {
// Should only be used once
nativeSslSession.invalidate();
session.invalidate();
}
nativeSslSession.setLastAccessedTime(System.currentTimeMillis());
session.setSessionDetails(nativeSslSession.getCreationTime(), nativeSslSession.getLastAccessedTime(),
nativeSslSession.sessionId(), nativeSslSession.keyValueStorage);
}
return reused;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does setSession() do?
setSession() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java.
Where is setSession() defined?
setSession() is defined in handler/src/main/java/io/netty/handler/ssl/OpenSslClientSessionCache.java at line 72.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free