PrimeFaces 8.0 DefaultStreamedContent.builder().stream() asks for SerializableSupplier<InputStream>

Everthing is in the migration guide here: https://github.com/primefaces/primefaces/wiki/Migration-Guide.

in general the following will work:

DefaultStreamedContent.builder().contentType(contentType).name(name).stream(() -> is).build();

But the idea behind the change is a different.
If you use a RequestScoped bean to build the StreamedContent, your bean and therefore the StreamedContent will be created twice:

  1. when rendering the view
  2. when streaming the resource (this is a new browser request!)

In this case, your is will probably created 2 times. Most of the times this results in 1 useless IO access or DB call.

To only create the is one time, you should lazy initialize it via the supplier lambda:

DefaultStreamedContent.builder().contentType(contentType).name(name).stream(() -> new FileInputStream(....)).build();