This bug has consequences on downstream projects depending on Netty:

https://play.lighthouseapp.com/projects/82401-play-20/tickets/511-adding-a-cookie-twice-to-a-result-doesnt-override-the-old-cookie
 Pull request: https://github.com/netty/netty/pull/379
 Merged into '3' and 'master'.  Thanks!

DefaultCookie equals and compareTo implementation wrong
The equals and compareTo implementations in DefaultCookie are wrong. Sample code from the equals method:

```
    if (getPath() == null && that.getPath() != null) {
        return false;
    } else if (that.getPath() == null) {
        return false;
    }
    if (!getPath().equals(that.getPath())) {
        return false;
    }
```

If path on both this and that is null, then the above code returns false, even though the cookies may be equal. The problem is in the else if statement, it should also check if getPath() doesn't equal null.  This affects both the equals and the compareTo methods, with the path and domain properties.

codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
index e94e5dc145f..cb5d3c6eaeb 100644
--- a/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
+++ b/codec-http/src/main/java/io/netty/handler/codec/http/DefaultCookie.java
@@ -273,7 +273,7 @@ public boolean equals(Object o) {
 
         if (getPath() == null && that.getPath() != null) {
             return false;
-        } else if (that.getPath() == null) {
+        } else if (that.getPath() == null && getPath() != null) {
             return false;
         }
         if (!getPath().equals(that.getPath())) {
@@ -282,7 +282,7 @@ public boolean equals(Object o) {
 
         if (getDomain() == null && that.getDomain() != null) {
             return false;
-        } else if (that.getDomain() == null) {
+        } else if (that.getDomain() == null && getDomain() != null) {
             return false;
         }
         return getDomain().equalsIgnoreCase(that.getDomain());
@@ -298,7 +298,7 @@ public int compareTo(Cookie c) {
 
         if (getPath() == null && c.getPath() != null) {
             return -1;
-        } else if (c.getPath() == null) {
+        } else if (c.getPath() == null && getPath() != null) {
             return 1;
         }
         v = getPath().compareTo(c.getPath());
@@ -308,7 +308,7 @@ public int compareTo(Cookie c) {
 
         if (getDomain() == null && c.getDomain() != null) {
             return -1;
-        } else if (c.getDomain() == null) {
+        } else if (c.getDomain() == null && getDomain() != null) {
             return 1;
         }
         v = getDomain().compareToIgnoreCase(c.getDomain());
