question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `StreamingOutput` or document alternative in RESTEasy Reactive

See original GitHub issue

Description

I have seen this issue discussed in both #26473 and #15891, but it still remains unclear to me how to do the equivalent of StreamingOutput with RESTEasy Reactive. If StreamingOutput cannot be directly supported as return type for blocking endpoints, I think it would make sense if the documentation provided some clear guidance on how to do this, including how to set headers (e.g. Content-Disposition as in the linked discussion), as RESTEasy Reactive is being promoted as the JAX-RS implementation of choice.

As in the discussion #26473 we also have a blocking endpoint which returns the output of some third-party library and having to first store that as a temporary file is IMO not very nice.

Implementation ideas

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
knutwannhedencommented, Oct 12, 2022

I will have to do some more testing, but I think this may do the trick and would allow my endpoints to transparently use StreamingOutput:

@Provider
public class StreamingOutputMessageBodyWriter implements MessageBodyWriter<StreamingOutput> {

    @Override
    public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
        return StreamingOutput.class.isAssignableFrom(aClass);
    }

    @Override
    public void writeTo(StreamingOutput blob, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream outputStream) throws IOException, WebApplicationException {
        blob.write(outputStream);
    }
}
0reactions
Manfred73commented, Nov 18, 2022

This workaround is a lifesaver! Been troubleshoothing for hours why I got some weird result back from the StreamingOutput (when processing it showed the classname$1… instead of the filecontent). Adding this StreamingOutputMessageBodyWriter does the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing RESTEasy Reactive - Quarkus
It gives the Quarkus and RESTEasy teams great pleasure to announce that RESTEasy Reactive integration in Quarkus has landed in the main ...
Read more >
RESTEasy JAX-RS - JBoss.org
Alternatively, Jackson's documentation suggest doing the same in a servlet filter; ... RESTEasy supports more reactive types than the specification.
Read more >
RestEasy reactive with javax.ws.rs.core.StreamingOutput
Hello,. While working on moving to rest easy reactive I ran into an issue with using javax.ws.rs.core.StreamingOutput to stream ...
Read more >
StreamingOutput (Java(TM) EE 7 Specification APIs)
Interface StreamingOutput. public interface StreamingOutput ... This is a lightweight alternative to a MessageBodyWriter . Since: 1.0; Author: Paul Sandoz, ...
Read more >
Jersey 2.37 User Guide - GitHub Pages
Implementing Support for Custom Reactive Libraries (SPI) ... Similarly, in case you spot any errors in the Jersey documentation, please report them by ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found