Skip to content

Comments

[Java] Fixes regression in method parameter transformation#6864

Merged
anuchandy merged 1 commit intomicrosoft:mainfrom
anuchandy:fix-media-types-1
Apr 4, 2025
Merged

[Java] Fixes regression in method parameter transformation#6864
anuchandy merged 1 commit intomicrosoft:mainfrom
anuchandy:fix-media-types-1

Conversation

@anuchandy
Copy link
Member

This PR addresses a regression introduced in the PR.

In 6737, a List<MethodTransformationDetails> representing mappings were replaced with a new type ParameterTransformations that composes an immutable list of mapping.

The original list was the JDK ArrayList<> that internally implements equals() and hashcode() (e.g., those equality impl ensures different list with zero elements as equal).

The new type ParameterTransformations introduced inherits the equals() and hashcode() from Object, so two distinct references are always different. Additionally, the composed immutable list is JDK ImmutableList, unlike ArrayList, it doesn’t not implement equals() and hashcode() but inherits Object's.

The ClientMethod composes ParameterTransformations (earlier List< MethodTransformationDetails >) property.

The generator needs to find distinct list of ClientMethods, and the proper comparison requires all composed properties type to support equality checks. So, with changes 6737, there were duplicate ClientMethod, resulting in emitted Java class to have same function appears twice.

Fixes: Azure/autorest.java#3061

Autorest PR

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Apr 3, 2025
@anuchandy anuchandy self-assigned this Apr 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2025

No changes needing a change description found.

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@anuchandy anuchandy enabled auto-merge April 3, 2025 23:37
@anuchandy anuchandy added this pull request to the merge queue Apr 3, 2025
Merged via the queue into microsoft:main with commit 83ae410 Apr 4, 2025
25 checks passed
@anuchandy anuchandy deleted the fix-media-types-1 branch April 4, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autorest, duplicate client method generated upon API with mulitple content-type

3 participants