8210311: IllegalArgumentException in CookieManager - Comparison method violates its general contract

Reviewed-by: chegar, dfuchs
This commit is contained in:
Michael McMahon 2018-09-13 12:07:01 +01:00
parent b395d380e8
commit b5fb6b3566
6 changed files with 240 additions and 19 deletions

View file

@ -142,6 +142,13 @@ public final class HttpCookie implements Cloneable {
}
private HttpCookie(String name, String value, String header) {
this(name, value, header, System.currentTimeMillis());
}
/**
* Package private for testing purposes.
*/
HttpCookie(String name, String value, String header, long creationTime) {
name = name.trim();
if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') {
throw new IllegalArgumentException("Illegal cookie name");
@ -152,7 +159,7 @@ public final class HttpCookie implements Cloneable {
toDiscard = false;
secure = false;
whenCreated = System.currentTimeMillis();
whenCreated = creationTime;
portlist = null;
this.header = header;
}
@ -756,6 +763,11 @@ public final class HttpCookie implements Cloneable {
throw new RuntimeException(e.getMessage());
}
}
// ---------------- Package private operations --------------
long getCreationTime() {
return whenCreated;
}
// ---------------- Private operations --------------