Skip to content

TestRestTemplate.withBasicAuth resets error handler #7441

@philwebb

Description

@philwebb

Originally raised here

Just a note about this: I discovered this issue when I called the method TestRestTemplate.withBasicAuth(String username, String password).

Inside that method is the call:

restTemplate.setErrorHandler(getRestTemplate().getErrorHandler());

...which sets the new RestTemplate's ErrorHandler with the current one. But then later in the method the TestRestTemplate constructor is called which then (re-)sets the just-set ResponseErrorHandler back to NoOpResponseErrorHandler.

This logic, along with the description in the javadoc for this method (Creates a new {@code TestRestTemplate} with the same configuration as this one), implies that the RestTemplate config should be the same as it was coming in, but it sets it to NoOpResponseErrorHandler regardless of the previous state.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions