snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Returning Uni<AsyncFile> doesn't work as described #429

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Describe the bug

Hello,

In documentation, it is stated that returning an AsyncFile or Uni<AsyncFile> should lead to contents of the file being returned, however, when I try to return Uni<AsyncFile>, or particularly Uni<io.vertx.mutiny.core.file.AsyncFile> which is by default returned from vertx.fileSystem().open(), what I get is just a string representation of the AsyncFile 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:

@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 vertx.eventBus().<JsonObject>request("photo", new JsonObject().put("id", id))
          .onItem().transformToUni(message -> vertx.fileSystem()
            .open(message.body().getString("path"), new OpenOptions().setRead(true)));  
    }
}

Output of uname -a or ver

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 or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response


https://github.com/quarkusio/quarkus/issues/20352


$upstream:20352$