Skip to content

ReactorNettyClientResponse should not throw exception if no body is available #32805

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

Closed
r16turbo opened this issue May 13, 2024 · 4 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@r16turbo
Copy link

Environment: Spring Web 6.1.6, Java 17

The situation is the same as in #31719, which occurs when using Reactor Netty.

The reason is that the following code throws an exception:

https://github.com/spring-projects/spring-framework/blob/v6.1.6/spring-web/src/main/java/org/springframework/http/client/ReactorNettyClientResponse.java#L85

I believe that null should also be returned when using Reactor Netty, please let me know about a better way to implement this.

Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 13, 2024
@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label May 13, 2024
@r16turbo
Copy link
Author

The server was the cause of the problem, not RestClient.
I'm sorry for all the fuss.

@r16turbo r16turbo closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 13, 2024
@r16turbo
Copy link
Author

r16turbo commented May 31, 2024

It seems that the RestClient is still the cause of the problem, so we will reopen.

Example of fix (Java 11 or higher):

https://github.com/spring-projects/spring-framework/blob/v6.1.6/spring-web/src/main/java/org/springframework/http/client/ReactorNettyClientResponse.java#L85

	@Override
	public InputStream getBody() throws IOException {
		InputStream body = this.body;
		if (body != null) {
			return body;
		}

		body = this.connection.inbound().receive()
				.aggregate().asInputStream().block(this.readTimeout);
		if (body == null) {
			// throw new IOException("Could not receive body");
			body = InputStream.nullInputStream();
		}
		this.body = body;
		return body;
	}

@r16turbo r16turbo reopened this May 31, 2024
@r16turbo r16turbo closed this as completed Jun 1, 2024
@bclozel bclozel reopened this Jun 1, 2024
@bclozel
Copy link
Member

bclozel commented Jun 1, 2024

See comment in #32934

@r16turbo
Copy link
Author

r16turbo commented Jun 1, 2024

Sorry, I didn't know if reopen or repost was better.
best regards.

@snicoll snicoll added status: waiting-for-triage An issue we've not yet triaged or decided on and removed status: invalid An issue that we don't feel is valid labels Jun 7, 2024
@poutsma poutsma self-assigned this Jun 13, 2024
@poutsma poutsma added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 13, 2024
@poutsma poutsma added this to the 6.1.9 milestone Jun 13, 2024
@poutsma poutsma changed the title RestClient ResponseSpec.body() when using Reactor Netty throws an exception instead of returning null if no response body is available ReactorNettyClientResponse should not throw exception if no body is available Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

6 participants