Skip to content

Conversation

hongjunan
Copy link

@hongjunan hongjunan commented Aug 12, 2021

org.springframework.web.reactive.function.server.support.ServerResponseResultHandler.java can NOT handle Mono<ServerResponse> or Flux<ServerResponse>.

public boolean supports(HandlerResult result) always return false.
because it check a returnValue type of HandlerResult .
need to replace a return type with a generic type of it.
see below error code.

	@Override
	public boolean supports(HandlerResult result) {
		return (result.getReturnValue() instanceof ServerResponse);
	}

fix like below
it has to compare with a generic type of returnType

	@Override
	public boolean supports(HandlerResult result) {
		return ServerResponse.class.isAssignableFrom(result.getReturnType().getGeneric().toClass());
	}

Related: https://github.com/spring-projects/spring-framework/issues/27266

@hongjunan hongjunan changed the title Bugfix/webflux Fix a ServerResponseResultHandler support method logic. #27266 Bugfix/webflux Fix a support method logic of ServerResponseResultHandler . #27266 Aug 12, 2021
@hongjunan hongjunan changed the title Bugfix/webflux Fix a support method logic of ServerResponseResultHandler . #27266 Bugfix/webflux Fix a support method logic of ServerResponseResultHandler . Aug 12, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 12, 2021
@ascopes
Copy link
Contributor

ascopes commented Aug 12, 2021

should this use .toClass().isAssignableFrom or .equals rather than class instance identity? (could see situations where this may be problematic in environments that use OSGi, for example).

@hongjunan
Copy link
Author

should this use .toClass().isAssignableFrom or .equals rather than class instance identity? (could see situations where this may be problematic in environments that use OSGi, for example).

Totally agree with your comment.
i fixed it. thank you.

https://github.com/spring-projects/spring-framework/pull/27268/commits/8e2c3f0d44b1613db4453ed599b6f173caddbd33

@rstoyanchev
Copy link
Contributor

We don't need both an issue and a PR, and typically, the issue is closed, but in this case the conversation is under way on the issue, and the PR is trivial. It can always be re-opened.

@rstoyanchev rstoyanchev added status: superseded An issue that has been superseded by another and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants