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

Support MessageBodyReader/Writer abstraction in Servlet #707

Merged
merged 2 commits into from
May 27, 2024

Conversation

graemerocher
Copy link
Contributor

@graemerocher graemerocher commented May 27, 2024

Servlet doesn't currently support the message body writer/reader abstraction. This fixes that.

@graemerocher graemerocher added the type: enhancement New feature or request label May 27, 2024
@graemerocher graemerocher requested a review from yawkat May 27, 2024 08:48
// could fill out the response! Blocking here will ensure that the response is filled out
// before the main response publisher completes. This will be improved later to avoid the block.
Flux.from(responseEncoder.encode(exchange, routeAnnotationMetadata, body)).blockLast();
if (body != null && !isVoid) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes a bug where void responses were still encoded to JSON

final MediaType mediaType = new MediaType(v[0]);
contentType(mediaType);
return mediaType;
if (body instanceof HttpResponseProvider responseProvider) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this prevents the body being set to itself (problem in JAX-RS implementation)

final Publisher<T> publisher = Publishers.just(content);
final T converted = conversionService.convertRequired(publisher, type);
return () -> Optional.of(converted);
if (name == null && messageBodyReader != null && messageBodyReader.isReadable(context.getArgument(), mediaType)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont like how this logic is duplicated in core and here but i think it will have to wait until i come up with a response byte body api

@graemerocher graemerocher force-pushed the message-body-writers2 branch from 2bf8a23 to a165b36 Compare May 27, 2024 09:23
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Bugs (required ≤ 0)
1 New Critical Issues (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@graemerocher graemerocher merged commit cc801ae into 4.8.x May 27, 2024
12 of 13 checks passed
@graemerocher graemerocher deleted the message-body-writers2 branch May 27, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants