1717
1818import io .netty .handler .codec .http .cookie .Cookie ;
1919import org .asynchttpclient .uri .Uri ;
20- import org .asynchttpclient .util .Assertions ;
2120import org .asynchttpclient .util .MiscUtils ;
2221import org .jetbrains .annotations .NotNull ;
2322import org .jetbrains .annotations .Nullable ;
3433import java .util .function .Predicate ;
3534import java .util .stream .Collectors ;
3635
36+ import static java .util .Objects .requireNonNull ;
37+
3738public final class ThreadSafeCookieStore implements CookieStore {
3839
3940 private final Map <String , Map <CookieKey , StoredCookie >> cookieJar = new ConcurrentHashMap <>();
@@ -88,7 +89,6 @@ public void evictExpired() {
8889 removeExpired ();
8990 }
9091
91-
9292 @ Override
9393 public int incrementAndGet () {
9494 return counter .incrementAndGet ();
@@ -226,8 +226,11 @@ private List<Cookie> getStoredCookies(String domain, String path, boolean secure
226226
227227 private void removeExpired () {
228228 final boolean [] removed = {false };
229- cookieJar .values ().forEach (cookieMap -> removed [0 ] |= cookieMap .entrySet ().removeIf (
230- v -> hasCookieExpired (v .getValue ().cookie , v .getValue ().createdAt )));
229+
230+ cookieJar .values ()
231+ .forEach (cookieMap -> removed [0 ] |= cookieMap .entrySet ()
232+ .removeIf (v -> hasCookieExpired (v .getValue ().cookie , v .getValue ().createdAt )));
233+
231234 if (removed [0 ]) {
232235 cookieJar .entrySet ().removeIf (entry -> entry .getValue () == null || entry .getValue ().isEmpty ());
233236 }
@@ -243,11 +246,12 @@ private static class CookieKey implements Comparable<CookieKey> {
243246 }
244247
245248 @ Override
246- public int compareTo (@ NotNull CookieKey o ) {
247- Assertions .assertNotNull (o , "Parameter can't be null" );
249+ public int compareTo (@ NotNull CookieKey cookieKey ) {
250+ requireNonNull (cookieKey , "Parameter can't be null" );
251+
248252 int result ;
249- if ((result = name .compareTo (o .name )) == 0 ) {
250- result = path .compareTo (o .path );
253+ if ((result = name .compareTo (cookieKey .name )) == 0 ) {
254+ result = path .compareTo (cookieKey .path );
251255 }
252256 return result ;
253257 }
0 commit comments