Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Viritin: How to handle exceptions in a LazyList.EntityProvider?
I'm using Viritin and its pretty nifty LazyList in combination with a slightly modified ListContainer as the data source for my Grid. I've provided the LazyList with an EntityProvider that fetches new rows from the database as needed. It works smoothly most of the time, but then I ran into a situation when a problem occurred during a database search for a particular page. The question is, how to handle this in a graceful way? I already log the exception and show an error message to the user, but an exception is still thrown from the Vaadin internals. If I return an empty list from findEntities(int firstRow), I end up with the following:
SEVERE:
java.lang.IndexOutOfBoundsException: Index: 0
at java.util.Collections$EmptyList.get(Collections.java:3212)
at org.vaadin.viritin.LazyList.get(LazyList.java:173)
at java.util.SubList.get(AbstractList.java:641)
at com.vaadin.server.communication.data.RpcDataProviderExtension.pushRowData(RpcDataProviderExtension.java:379)
at com.vaadin.server.communication.data.RpcDataProviderExtension.access$900(RpcDataProviderExtension.java:65)
at com.vaadin.server.communication.data.RpcDataProviderExtension$2.requestRows(RpcDataProviderExtension.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at java.lang.reflect.Method.invoke(Method.java:601)
If I return null, I end up with the following:
SEVERE:
java.lang.NullPointerException
at com.vaadin.ui.Grid$RowDataGenerator.writeData(Grid.java:2192)
at com.vaadin.ui.Grid$RowDataGenerator.generateData(Grid.java:2152)
at com.vaadin.server.communication.data.RpcDataProviderExtension.getRowData(RpcDataProviderExtension.java:395)
at com.vaadin.server.communication.data.RpcDataProviderExtension.pushRowData(RpcDataProviderExtension.java:383)
at com.vaadin.server.communication.data.RpcDataProviderExtension.access$900(RpcDataProviderExtension.java:65)
at com.vaadin.server.communication.data.RpcDataProviderExtension$2.requestRows(RpcDataProviderExtension.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at java.lang.reflect.Method.invoke(Method.java:601)
The exceptions are not logged (nor should they), but they cause visual problems. The Grid is rendered full of empty rows (as EntityProvider.size() worked properly), with the columns squeezed really narrow, and the component error marker (exclamation mark) appears next to the grid. Question is, can I avoid this somehow? I'd like the Grid to be rendered as empty without any rows, and no component error markers. The problem is that I have no way of catching those exceptions and handling them.