Skip to content

fix: [OData] Revert mutability of ODataResourcePath and resolve segment duplication - #1138

Merged
rpanackal merged 2 commits into
mainfrom
fix/odata/revert-regression-1121
Apr 7, 2026
Merged

fix: [OData] Revert mutability of ODataResourcePath and resolve segment duplication#1138
rpanackal merged 2 commits into
mainfrom
fix/odata/revert-regression-1121

Conversation

@rpanackal

@rpanackal rpanackal commented Apr 2, 2026

Copy link
Copy Markdown
Member

Context

SAP/cloud-sdk-java-backlog#ISSUENUMBER.

Fix for regression in #1121.

Previously known issue: InCountRequestBuilder.toRequest(): calling toRequest() twice on the same builder would produce corrupted paths like Trips/$count/$count instead of Trips/$count

The original pull request resolved the issue by making ODataResourcePath immutable.

But by doing so, code that relied on mutability of ODataResourcePath failed silently.

ODataResourcePath path = new ODataResourcePath();
path.addSegment("A_BusinessPartner");  // return value discarded

// Next `someMethod(path)` call, don't pass along the expected segment "A_BusinessPartner"

Feature scope:

  • Introduce a public copy() method in ODataResourcePath for defensive copy
    • Not advertised in release notes
  • ODataRequestRead, ODataRequestCount, ODataRequesReadByKey, ODataRequestFunction and ServiceWithNavigableEntitiesImpl now create a defensive copy before respective operation.

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated
* @return A new {@link ODataResourcePath} with the same segments as this path.
*/
@Nonnull
public ODataResourcePath copy()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Please add @Beta annotation and @since tag :)

@Jonas-Isr Jonas-Isr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@rpanackal
rpanackal merged commit ddb0316 into main Apr 7, 2026
13 checks passed
@rpanackal
rpanackal deleted the fix/odata/revert-regression-1121 branch April 7, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants