@Override public List<Header> formatCookies(final List<Cookie> cookies) { Args.notEmpty(cookies, "List of cookies"); List<Cookie> cookieList; if (cookies.size() > 1) { // Create a mutable copy and sort the copy. cookieList = new ArrayList<Cookie>(cookies); Collections.sort(cookieList, CookiePathComparator.INSTANCE); } else { cookieList = cookies; } if (this.oneHeader) { return doFormatOneHeader(cookieList); } else { return doFormatManyHeaders(cookieList); } }