Github user bitstorm commented on the issue:
I agree about the use of a normal boolean, but I'm not sure I've understood your idea about ThreadLocal. What I would like to do is to prevent race conditions inside storeTouchedPages. I would do it using synchronized on entry object:
protected void storeTouchedPages(final List<IManageablePage> touchedPages)
SessionEntry entry = getSessionEntry(true);
for (IManageablePage page : touchedPages)
// WICKET-5103 use the same sessionId as used in SessionEntry#getPage()
In this way two possible concurrent requests for the same session would execute storeTouchedPages one at a time.