in src/main/kotlin/org/opensearch/replication/util/Coroutines.kt [226:239]
override fun updateThreadContext(cc: CoroutineContext) {
this.context.close()
if(!init) {
// To ensure, we initialize security related transients only once
this.context = if(injectSecurityContext || defaultContext)
threadContext.stashContext()
else
threadContext.newStoredContext(true)
if(injectSecurityContext) {
// Populate relevant transients from replication metadata
SecurityContext.setBasedOnActions(replicationMetadata, action, threadContext)
}
}
}