-
Notifications
You must be signed in to change notification settings - Fork 357
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
Can not serialize CompletionStage<Response> #5103
Comments
This looks more like a Yasson issue. |
The thing is that Jersey does not handle |
Jsonb impl(Yasson) provides basic serialization for general purpose. But I do think it is the responsibility of Yasson. As a Jaxrs impl, to support Async using Java 8 As you mentioned, to get a list( Quarkus supports such an approach in the early version, check my example CompletableFuture, in the new version, it is replaced by RactiveStreams(Small Mutiny). In contrast to Spring, besides the async So I think to support async in Jaxrs, it should add it own serializer to handle |
|
I would like use @GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<Response> getAllPosts() {
return this.posts.findAll().thenApply(posts -> ok(posts).build());
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
public CompletionStage<Response> savePost(@Valid Post post/*, @Context UriInfo uriInfo*/) {
//uriInfo.getBaseUriBuilder().path("/posts/{id}").build(id.toString())
return this.posts.save(post).thenApply(id -> created(URI.create("/posts/" + id.toString())).build());
}
@Path("{id}")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public CompletionStage<Response> updatePost(@PathParam("id") final String id, @Valid Post post) {
return this.posts.update(UUID.fromString(id), post)
.thenApply(updated -> updated > 0 ? Status.NO_CONTENT : Status.NOT_FOUND)
.thenApply(status -> status(status).build());
}
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<Response> getPostById(@PathParam("id") final String id) {
return this.posts.findById(UUID.fromString(id))
.thenApply(post -> ok(post).build())
.exceptionally(throwable -> {
LOGGER.log(Level.WARNING, " failed to get post by id :", throwable);
return status(NOT_FOUND).build();
});
}
@DELETE
@Path("{id}")
public CompletionStage<Response> delete(@PathParam("id") String id) {
return this.posts.delete(id)
.thenApply(deleted -> deleted > 0 ? Status.NO_CONTENT : Status.NOT_FOUND)
.thenApply(status -> status(status).build());
} And we are moving to Java 11, Java 9 Flow(and ReactiveStreams, there are some utility available to convert from/to Java 9 Flow) |
It is not included in the Glassfish 7.0.0-M9? The detailed exception in Glassfish 7.0.0-M9: eclipse-ee4j/glassfish#24121 |
Glassfish 7.0.0-M7
Java 17
Windows 10
Sample Jaxrs resource return a
CompletionStage<Response>
.When running the test TodoResourceTest, and got the following exceptions in the server.log.
Attached the completed server.log
The text was updated successfully, but these errors were encountered: