Package org.apache.catalina.util
Class SessionComparators
- java.lang.Object
-
- org.apache.catalina.util.SessionComparators
-
public class SessionComparators extends java.lang.ObjectUtility class for buildingComparators overSessions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Comparator<Session>comparingLongSnapshot(java.util.function.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 Detail
-
comparingLongSnapshot
public static java.util.Comparator<Session> comparingLongSnapshot(java.util.function.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. 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
-
-