Sean-Walker0 commented on PR #7317:
URL: https://github.com/apache/shenyu/pull/7317#issuecomment-5847066321
Thanks for the fix — verified it covers the root cause cleanly. (I had
opened #7318 on the same issue 14 minutes after this one; closing it in favor
of this patch.)
One optional hardening, which @Aias00 asked to preserve from #7318:
`removeSessionIndexes` only consults the remembered namespace, so a session
that ever lands in `NAMESPACE_SESSION_MAP` without a `SESSION_NAMESPACE_IDS`
entry would be missed. A fallback branch covers that:
```java
String namespaceId = SESSION_NAMESPACE_IDS.remove(session);
if (StringUtils.isNotBlank(namespaceId)) {
NAMESPACE_SESSION_MAP.compute(namespaceId, (id, sessions) -> {
if (Objects.isNull(sessions)) {
return null;
}
sessions.remove(session);
return sessions.isEmpty() ? null : sessions;
});
} else {
// no remembered namespace: sweep every set, idempotent and O(number of
namespaces)
NAMESPACE_SESSION_MAP.values().forEach(sessions ->
sessions.remove(session));
}
```
Purely defense-in-depth today — `onOpen` is the only registration path and
it always records the id — but it keeps teardown correct if a future path ever
adds to the map without remembering the namespace. Happy to send a follow-up PR
if maintainers want it; otherwise feel free to disregard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]