Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially unsafe usage of WebClient in ReactiveVaultTemplate #612

Closed
robotmrv opened this issue Dec 24, 2020 · 1 comment
Closed

Potentially unsafe usage of WebClient in ReactiveVaultTemplate #612

robotmrv opened this issue Dec 24, 2020 · 1 comment
Labels
type: bug A general bug
Milestone

Comments

@robotmrv
Copy link

There are several unsafe places which could lead to resource (connections, byte buffers) leaks

  1. mapOtherwise() could return Mono.empty() without ClientResponse consumption
    https://github.com/spring-projects/spring-vault/blob/master/spring-vault-core/src/main/java/org/springframework/vault/core/ReactiveVaultTemplate.java#L338-L343
	private static <T> Mono<? extends T> mapOtherwise(ClientResponse response, String path, HttpMethod method) {

		if (response.statusCode() == HttpStatus.NOT_FOUND && method == HttpMethod.GET) {
			return Mono.empty();//<-- 
		}

		return response.bodyToMono(String.class).flatMap(body -> {

			String error = VaultResponses.getError(body);

			return Mono.error(VaultResponses.buildException(response.statusCode(), path, error));
		});
	}
  1. usage of unsafe deprecated exchange().
    WebClient.RequestHeadersSpec#exchangeToMono() or WebClient.ResponseSpec#toEntity() could be used instead.
@mp911de mp911de added the type: bug A general bug label Dec 24, 2020
@mp911de mp911de added this to the 2.3.1 milestone Jan 15, 2021
mp911de added a commit that referenced this issue Jan 15, 2021
We now use exchangeToMono(…) for a safe release of the body.

Closes gh-612
@mp911de
Copy link
Member

mp911de commented Jan 15, 2021

Thanks a lot, we now moved off the deprecated API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants