Skip to content

MLE-30667 Added toString() override to ClientCookie#1949

Merged
jonmille merged 1 commit into
developfrom
MLE-30667
Jun 24, 2026
Merged

MLE-30667 Added toString() override to ClientCookie#1949
jonmille merged 1 commit into
developfrom
MLE-30667

Conversation

@jonmille

@jonmille jonmille commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Fixes a bug where ClientCookie.toString() returned the default Object.toString() value
(com.marklogic.client.ClientCookie@<hashcode>) instead of name=value. This caused
OkHttpServices.addCookies() to set a malformed Cookie request header, silently breaking
load balancer session affinity (e.g., HAProxy HostId affinity) for multi-statement transactions.
Requests could land on different backend nodes, resulting in XDMP-NOTXN: No transaction with identifier errors.

Changes

  • ClientCookie.java — Added toString() override returning name + "=" + value
  • ClientCookieTest.java — New unit test class with two tests covering the standard
    name=value format and the empty-value edge case

Testing

  • ClientCookieTest passes (no MarkLogic instance required)
  • No existing tests broken

Related

Added a toString() override that returns `name + "=" + value`.
Copilot AI review requested due to automatic review settings June 23, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect Cookie request header formatting by ensuring ClientCookie.toString() returns a standard name=value representation, restoring load balancer session affinity behavior for multi-statement transactions in the Java client.

Changes:

  • Added ClientCookie.toString() override to emit name=value.
  • Added ClientCookieTest with coverage for normal and empty-value cookie formatting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
marklogic-client-api/src/main/java/com/marklogic/client/ClientCookie.java Overrides toString() so cookies serialize as name=value for request header usage.
marklogic-client-api/src/test/java/com/marklogic/client/test/ClientCookieTest.java Adds unit tests validating ClientCookie.toString() output for typical and empty-value cases.

Comment on lines +59 to +62
@Override
public String toString() {
return name + "=" + value;
}
@jonmille jonmille merged commit 7a8afd8 into develop Jun 24, 2026
4 of 5 checks passed
@jonmille jonmille deleted the MLE-30667 branch June 24, 2026 14:11
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.

4 participants