Open boraxhacker opened 6 years ago
Appears perhaps lambda? is what is causing the problem. Using an anonymous class works.
@GET
@Path("/reports/{id}")
@Produces(MediaType.APPLICATION_XML)
public Response retrieveReportXml(@NotNull @PathParam("id") UUID id)
throws IOException {
StreamingOutput result = new StreamingOutput() {
@Override
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
ReportResource.this.reportXmlService.exportReport(id, outputStream);
outputStream.flush();
}
};
return Response.ok(result, MediaType.APPLICATION_XML_TYPE).build();
}
Similar to #3310 it would be nice (and provides convenient workaround for this issue) to annotate the resource class method with code>@InjectLinkNoFollow</code and short circuit the ResponseLinkFilter.
public void filter(ContainerRequestContext request, ContainerResponseContext response) {
Object entity = response.getEntity();
if (entity != null
&& !this.uriInfo.getMatchedResources().isEmpty()
&& !Stream.of(response.getEntityAnnotations()).anyMatch(ann -> InjectNoFollow.class.equals(ann.getAnnotationType())) {
This code throws an exception[1]
if the Response entity is changed so that the processLinks method short circuits
using a byte[] then the method will return properly.
[1]exception stack excerpt
[2] version