-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Returning Uni<AsyncFile> doesn't work as described #20352
Comments
I also have an additional related question: is returning a |
@madprogrammer which REST extension do you use? |
@michalszynkiewicz in "Installed features" the following relevant extensions are listed: |
@michalszynkiewicz it seems to be related specifically to Mutiny API. I've rewrited the code without Mutiny to test, and it works: @javax.ws.rs.Path("/photo")
@ApplicationScoped
public class PhotoResource {
private final Vertx vertx;
@Inject
public PhotoResource(Vertx vertx) {
this.vertx = vertx;
}
@GET
@Blocking
@Produces("image/jpeg")
public Uni<AsyncFile> getPhoto(@QueryParam("id") String id) {
return Uni.createFrom().emitter(emitter -> {
vertx.eventBus().<JsonObject>request("photo", new JsonObject().put("id", id), ar -> {
if (ar.failed()) {
emitter.fail(ar.cause());
} else {
String path = ar.result().body().getString("path");
vertx.fileSystem().open(path, new OpenOptions().setRead(true), result -> {
if (result.failed()) {
emitter.fail(result.cause());
} else {
emitter.complete(result.result());
}
});
}
});
});
}
} |
Nevermind, I just read your last post. I will provide a fix for allowing the Mutity type as well. |
#20374 fixes the issue |
Support the Mutiny AsyncFile type as a return type
Fixes: quarkusio#20352 (cherry picked from commit 1a148e3)
Describe the bug
Hello,
In documentation, it is stated that returning an
AsyncFile
orUni<AsyncFile>
should lead to contents of the file being returned, however, when I try to returnUni<AsyncFile>
, or particularlyUni<io.vertx.mutiny.core.file.AsyncFile>
which is by default returned fromvertx.fileSystem().open()
, what I get is just a string representation of theAsyncFile
class.Expected behavior
The contents of the file should be returned by the server
Actual behavior
A reply with following content is returned
io.vertx.core.file.impl.AsyncFileImpl@54d3c384
How to Reproduce?
The following code reproduces the problem for me:
Output of
uname -a
orver
Microsoft Windows [Version 10.0.19043.1237]
Output of
java -version
openjdk version "11.0.10" 2021-01-19 LTS
GraalVM version (if different from Java)
OpenJDK Runtime Environment GraalVM CE 21.2.0 (build 11.0.12+6-jvmci-21.2-b08)
Quarkus version or git rev
2.2.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Additional information
No response
The text was updated successfully, but these errors were encountered: