Hi,
I am using jmix 2.2.3. and I have problem downloading PDFs.
I am using following code to download PDF:
downloader.download(
reportService.createReportFromResult(editedEntity),
"report.pdf",
DownloadFormat.PDF
)
pdf file is created in runtime as byte array. It is opened in new window and it is displayed correctly as expected and I am able to download report correctly in firefox. But in chrome, when I hit download button in newly opened window (that is displaying generated PDF) it downloads empty file with 0 bytes and I get following exception:
java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "source" is null
at com.vaadin.flow.server.StreamResource$Pipe.read(StreamResource.java:119) ~[flow-server-24.3.8.jar:24.3.8]
at com.vaadin.flow.server.StreamResource$Pipe.copy(StreamResource.java:109) ~[flow-server-24.3.8.jar:24.3.8]
at com.vaadin.flow.server.StreamResource$Pipe.accept(StreamResource.java:84) ~[flow-server-24.3.8.jar:24.3.8]
at io.jmix.flowui.component.filedownloader.JmixFileDownloader.lambda$runCommand$18809115$1(JmixFileDownloader.java:121) ~[jmix-flowui-2.2.3.jar:na]
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[na:na]
at io.jmix.flowui.component.filedownloader.JmixFileDownloader.lambda$beforeClientResponseDownloadHandler$69016e48$1(JmixFileDownloader.java:158) ~[jmix-flowui-2.2.3.jar:na]
at com.vaadin.flow.server.communication.SessionRequestHandler.handleRequest(SessionRequestHandler.java:64) ~[flow-server-24.3.8.jar:24.3.8]
at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1574) ~[flow-server-24.3.8.jar:24.3.8]
at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:398) ~[flow-server-24.3.8.jar:24.3.8]
omiting DownloadFormat.PDF
has no effect.
It is happening both when running from IDE or when using compiled and deployed application.
Firefox version: 126.0
Chrome version: 124.0.6367.118
OS: Ubuntu 22.04 (both desktop and server where jmix app is deployed)