Hoist random() calls out of session synch blocks

This commit is contained in:
zzz
2026-05-10 09:06:00 -04:00
parent dfaa5c3f81
commit 85499fbb8b
3 changed files with 6 additions and 9 deletions
@@ -55,15 +55,14 @@ public class CSSHelper extends HelperBase {
//I2PAppContext.getGlobalContext().logManager().getLog(CSSHelper.class).error("getNonce() null session", new Exception());
return "FAIL_SESSION_NOT_SET";
}
String rv;
// add a prefix to distinguish from other nonces for debugging
String rv = "CN" + RandomSource.getInstance().nextLong();
synchronized(session) {
LinkedList<String> nonces = (LinkedList<String>) session.getAttribute(SESSION_CONSOLE_NONCE);
if (nonces == null) {
nonces = new LinkedList<String>();
session.setAttribute(SESSION_CONSOLE_NONCE, nonces);
}
// add a prefix to distinguish from other nonces for debugging
rv = "CN" + RandomSource.getInstance().nextLong();
nonces.offer(rv);
if (nonces.size() > NONCE_QUEUE_SIZE)
nonces.poll();