This is an optimization for distributed session managers, where calls to setAttribute(...) are expensive. There's no reason to store the bean index hash in the session if the bean index is empty.