private Request makeUpgradeRequest(long sessionId) { // Make sure to atomically check local session status, upgrade // session, and make the session creation request. This is to // avoid another thread upgrading the session in parallel. synchronized (upgradeableSessionTracker) { if (upgradeableSessionTracker.isLocalSession(sessionId)) { int timeout = upgradeableSessionTracker.upgradeSession(sessionId); ByteBuffer to = ByteBuffer.allocate(4); to.putInt(timeout); return new Request( null, sessionId, 0, OpCode.createSession, to, null); } } return null; }