@Override
    public void set(URI uri, Iterable<? extends Cookie> cookies, long createdTimeMillis) {
        requireNonNull(uri, "uri");
        requireNonNull(cookies, "cookies");
        lock.lock();
        try {
            for (Cookie cookie : cookies) {
                final Cookie ensuredCookie = ensureDomainAndPath(cookie, uri);
                // remove similar cookie if present
                store.removeLong(ensuredCookie);
                if ((ensuredCookie.maxAge() == Cookie.UNDEFINED_MAX_AGE || ensuredCookie.maxAge() > 0) &&
                    cookiePolicy.accept(uri, ensuredCookie)) {
                    store.put(ensuredCookie, createdTimeMillis);
                    final Set<Cookie> cookieSet = filter.computeIfAbsent(ensuredCookie.domain(),
                                                                         s -> new HashSet<>());

                    // remove the cookie with the same name, domain, and path if present
                    // https://datatracker.ietf.org/doc/html/rfc6265#page-24
                    final Cookie oldCookie = cookieSet.stream()
                                                      .filter(c -> isSameNameAndPath(c, ensuredCookie))
                                                      .findFirst()
                                                      .orElse(null);
                    if (oldCookie == null) {
                        cookieSet.add(ensuredCookie);
                        continue;
                    }
                    if (!("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) &&
                        oldCookie.isHttpOnly()) {
                        // if the new cookie is received from a non-HTTP and the old cookie is http-only, skip
                        continue;
                    }
                    cookieSet.remove(oldCookie);
                    cookieSet.add(ensuredCookie);
                }
            }
        } finally {
            lock.unlock();
        }
    }
Used to find cookies for a host that matches a domain. For example, if there is a domain example.com,
host example.com or foo.example.com will match all cookies in that entry.
core/src/main/java/com/linecorp/armeria/client/cookie/DefaultCookieJar.java