Details
-
Bug
-
Status: Closed (View Workflow)
-
TBD
-
Resolution: Done
-
2.5.1, 2.6.0
-
-
CP: sprint 104
-
1
-
Core: Platform
Description
MainVerticle.LimitedSizeQueue<K> extends ArrayList<K>: https://github.com/folio-org/mod-authtoken/blob/v2.6.0/src/main/java/org/folio/auth/authtokenmodule/MainVerticle.java#L874-L889
tokenCache.contains(authToken) is a linear search through the array: https://github.com/folio-org/mod-authtoken/blob/v2.6.0/src/main/java/org/folio/auth/authtokenmodule/MainVerticle.java#L496
Use a better implementation, for example
https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html
with
@Override protected boolean removeEldestEntry(Map.Entry eldest) { return size() > MAX_ENTRIES; }
On top of that the current implementation is broken. Size of LimitedSizeQueue is not limited. Size of queue may be larger than maxSize.