Skip to content

[Java][WebClient][RestClient] Standardize useAbstractionForFiles behavior to use Resource interface #23381

@Nawrok

Description

@Nawrok

The current implementation of file handling across different Java generator libraries is inconsistent when using the useAbstractionForFiles property. While the resttemplate library was successfully updated to use Spring's org.springframework.core.io.Resource interface (via PR #7051), the webclient and restclient generators have not been aligned with this standard. They still rely on the AbstractResource class or lack the unified abstraction entirely.

This inconsistency creates challenges when maintaining shared code or migrating between HTTP clients (e.g. from resttemplate to webclient or restclient), as it requires implementing client-specific workarounds for file handling.

Solution

I propose standardizing the behavior of the useAbstractionForFiles property across the webclient and restclient libraries to match the implementation introduced for resttemplate.

Specifically, when useAbstractionForFiles is enabled, both webclient and restclient should generate code that utilizes the org.springframework.core.io.Resource interface instead of the AbstractResource class. This will ensure uniform and seamless file handling across all Spring-based Java generators.

Additional context

This request is a continuation of the broader effort to improve and standardize file handling in Java generators.
For reference, please see the related discussions and PRs:

Issue #6715: [Java] useAbstractionForFiles does not work for spring / webclient

PR #7051: [Java][RestTemplate] Use Spring Resource interface instead of AbstractResource for file abstraction (reference implementation)

PR #7567: [Java][Webclient] Fix useAbstractionForFiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions