-
Notifications
You must be signed in to change notification settings - Fork 74
MLE-24405 Making ClientCookie a real public class #1825
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
Conversation
Copyright Validation Results ✅ Valid Files
✅ All files have valid copyright headers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR moves ClientCookie from the impl package to the public API package and refactors it from a wrapper around OkHttp Cookie to a simple immutable data class holding cookie values directly.
- Moved ClientCookie from
com.marklogic.client.impl
tocom.marklogic.client
package - Simplified ClientCookie implementation to hold cookie values directly instead of wrapping OkHttp Cookie
- Removed unnecessary cloning operations when adding cookies to transactions and sessions
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
marklogic-client-api/src/main/java/com/marklogic/client/impl/TransactionImpl.java | Updated import path and removed cookie cloning, fixed typo in comment |
marklogic-client-api/src/main/java/com/marklogic/client/impl/SessionStateImpl.java | Added import and removed cookie cloning |
marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java | Added private method to parse cookies and updated calls |
marklogic-client-api/src/main/java/com/marklogic/client/impl/ClientCookie.java | Deleted old implementation |
marklogic-client-api/src/main/java/com/marklogic/client/Transaction.java | Removed impl package import |
marklogic-client-api/src/main/java/com/marklogic/client/ClientCookie.java | New simplified implementation as immutable data class |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
||
private static ClientCookie parseClientCookie(HttpUrl url, String setCookieHeaderValue) { | ||
Cookie cookie = Cookie.parse(url, setCookieHeaderValue); | ||
if(cookie == null) throw new IllegalStateException(setCookieHeaderValue + "is not a well-formed cookie"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space in error message. Should be: setCookieHeaderValue + \" is not a well-formed cookie\"
if(cookie == null) throw new IllegalStateException(setCookieHeaderValue + "is not a well-formed cookie"); | |
if(cookie == null) throw new IllegalStateException(setCookieHeaderValue + " is not a well-formed cookie"); |
Copilot uses AI. Check for mistakes.
// make a clone to ensure we're not holding on to any resources | ||
// related to an HTTP connection that need to be released | ||
this.cookies.add(new ClientCookie(cookie)); | ||
this.cookies.add(cookie); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation. This line uses tabs while the surrounding code uses spaces. Should use spaces to match the existing code style.
this.cookies.add(cookie); | |
this.cookies.add(cookie); |
Copilot uses AI. Check for mistakes.
This was already in the public API via the Transaction interface, but it was in the "impl" package. I also can't determine any reason why it was reconstructing an OkHttp Cookie and then holding onto it. The Cookie class is immutable - but ClientCookie was already being given the immutable values that it needed. So no idea why ClientCookie was then rebuilding an OkHttp Cookie. It no longer does that - it's just a simple bean now, holding onto the values of interest that were extracted from an OkHttp Cookie.
d1b6133
to
ab3ea02
Compare
This was already in the public API via the Transaction interface, but it was in the "impl" package.
I also can't determine any reason why it was reconstructing an OkHttp Cookie and then holding onto it. The Cookie class is immutable - but ClientCookie was already being given the immutable values that it needed. So no idea why ClientCookie was then rebuilding an OkHttp Cookie. It no longer does that - it's just a simple bean now, holding onto the values of interest that were extracted from an OkHttp Cookie.