-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid possible comparison contract violation #9883
Conversation
The current implementation would violate comparison contract for two cookies C1 and C2 with same path length, since C1 < C2 and C2 < C1. Returning 0 (equality) does not since C1 == C2 and C2 == C1. See netty#9881
Can one of the admins verify this patch? |
@gerdriesselmann can't you add a test case that validates |
@gerdriesselmann also please sign our icla if you didn't already: https://netty.io/s/icla |
@normanmaurer icla was signed. Regarding a test: since this is a private class of ClientCookieEncoder, I have no real idea how to write a test against it. |
@gerdriesselmann make it package-private :) |
@normanmaurer To be honest, I'm doing Scala, but am rather alienated by the Java language and its tooling in general and Maven especially. I tried to execute the existing ClientCookieEncoderTest within IntelliJ, but can't compile against Java 11, and get "Unrecognized option: --illegal-access=deny" against Java 8. Additionally, as soon as I'm changing something (like adding a test case), a CheckStyle plugin jumps in and stops me from progressing. I can't even figure out what exactly it complains about... Sorry to be of no further help here... |
codec-http/src/main/java/io/netty/handler/codec/http/cookie/ClientCookieEncoder.java
Show resolved
Hide resolved
codec-http/src/main/java/io/netty/handler/codec/http/cookie/ClientCookieEncoder.java
Show resolved
Hide resolved
@netty-bot test this please |
@gerdriesselmann I will add a unit test as followup once this is in. Thanks! |
@gerdriesselmann merged... thanks a lot. |
Motivation: The current implementation causes IllegalArgumetExceptions to be thrown on Java 11. The current implementation would violate comparison contract for two cookies C1 and C2 with same path length, since C1 < C2 and C2 < C1. Returning 0 (equality) does not since C1 == C2 and C2 == C1. See #9881 Modification: Return equality instead of less than on same path length. Result: Fixes #9881.
Motivation: #9883 added a bug-fix for the Comparator in ClientCookieEncoder but did not add a testcase. Modifications: - Add testcase - Simplify code Result: Include a test to ensure we not regress.
Motivation: #9883 added a bug-fix for the Comparator in ClientCookieEncoder but did not add a testcase. Modifications: - Add testcase - Simplify code Result: Include a test to ensure we not regress.
Motivation: #9883 added a bug-fix for the Comparator in ClientCookieEncoder but did not add a testcase. Modifications: - Add testcase - Simplify code Result: Include a test to ensure we not regress.
Motivation: The current implementation causes IllegalArgumetExceptions to be thrown on Java 11. The current implementation would violate comparison contract for two cookies C1 and C2 with same path length, since C1 < C2 and C2 < C1. Returning 0 (equality) does not since C1 == C2 and C2 == C1. See netty#9881 Modification: Return equality instead of less than on same path length. Result: Fixes netty#9881.
…ty#9897) Motivation: netty#9883 added a bug-fix for the Comparator in ClientCookieEncoder but did not add a testcase. Modifications: - Add testcase - Simplify code Result: Include a test to ensure we not regress.
The current implementation would violate comparison contract for two cookies C1 and C2 with same path length, since C1 < C2 and C2 < C1. Returning 0 (equality) does not since C1 == C2 and C2 == C1. See #9881
Motivation:
The current implementation causes IllegalArgumetExceptions to be thrown on Java 11.
Modification:
Return equality instead of less than on same path length.
Result:
Fixes #9881.