Skip to content

Conversation

rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Sep 30, 2025

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.

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 14:11
Copy link

github-actions bot commented Sep 30, 2025

Copyright Validation Results
Total: 5 | Passed: 5 | Failed: 0 | Skipped: 0 | at: 2025-09-30 14:16:34 UTC | commit: ab3ea02

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/ClientCookie.java
  • marklogic-client-api/src/main/java/com/marklogic/client/Transaction.java
  • marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java
  • marklogic-client-api/src/main/java/com/marklogic/client/impl/SessionStateImpl.java
  • marklogic-client-api/src/main/java/com/marklogic/client/impl/TransactionImpl.java

✅ All files have valid copyright headers!

Copy link

@Copilot Copilot AI left a 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 to com.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");
Copy link
Preview

Copilot AI Sep 30, 2025

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\"

Suggested change
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);
Copy link
Preview

Copilot AI Sep 30, 2025

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.

Suggested change
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.
@rjrudin rjrudin force-pushed the feature/move-client-cookie branch from d1b6133 to ab3ea02 Compare September 30, 2025 14:16
@rjrudin rjrudin merged commit 9ee3b91 into develop Sep 30, 2025
3 checks passed
@rjrudin rjrudin deleted the feature/move-client-cookie branch September 30, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants