Skip to content

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

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

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

Conversation

@rpanackal
Copy link
Copy Markdown
Member

@rpanackal rpanackal commented Apr 2, 2026

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 :)

Copy link
Copy Markdown
Member

@Jonas-Isr Jonas-Isr left a comment

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants