Class SessionComparators
java.lang.Object
org.apache.catalina.util.SessionComparators
Utility class for building
Comparators over Sessions.-
Method Summary
Modifier and TypeMethodDescriptionstatic Comparator<Session> comparingLongSnapshot(ToLongFunction<Session> keyExtractor) Builds aComparatorequivalent toComparator.comparingLong(ToLongFunction), except that each session's extracted value is only read once and then cached for the remainder of the sort.
-
Method Details
-
comparingLongSnapshot
Builds aComparatorequivalent toComparator.comparingLong(ToLongFunction), except that each session's extracted value is only read once and then cached for the remainder of the sort. Some values used to sort sessions (e.g. last accessed time, or values derived from the current time) can change while a sort is in progress, either because the session is concurrently accessed or simply because time passes. Without caching, that can make the comparator return inconsistent results for the same pair of sessions across different comparisons in the same sort, which tripsjava.util.TimSort's consistency check.- Parameters:
keyExtractor- Function that extracts the sort key from a session- Returns:
- a comparator that sorts sessions by the (cached) extracted key
-