Skip to content

HttpComponents5MessageSender overrides HttpClient when set as a property #1512

Closed
@ekonijn

Description

@ekonijn

In org.springframework.ws.transport.http.HttpComponents5MessageSender.afterPropertiesSet() (retrieved 26mar25), if you use property injection instead of constructor injection to set the httpClient, the httpClient is silently overwritten by the clientFactory.

This user error would be easier to diagnose if you added a check in afterPropertiesSet(), similar to the check in other methods:

        @Override
        public void afterPropertiesSet() throws Exception {
                if (this.clientFactory != null) {
                        if (getHttpClient() != null) {
                                throw new IllegalStateException(HTTP_CLIENT_ALREADY_SET);
                        }
                        this.httpClient = this.clientFactory.getObject();
                }
        }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions