Issues with Table Component

I have been getting errors like the following with the Table component on Vaadin 6.4.8:


java.lang.ArrayIndexOutOfBoundsException
	at com.vaadin.ui.Table.paintContent(Table.java:2400)
	at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:754)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:807)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:621)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

On the Table.paintContent, it appears to be iterating over the cells with:


        int end = cells[0]
.length;
        if (reqRowsToPaint != -1) {
            end = start + reqRowsToPaint;
        }

...

            final Object itemId = cells[CELL_ITEMID]
[indexInRowbuffer]
;

Now it appears that “end” gets reset with the reqRowsToPaint and in my case, the reqRowsToPaint does not always match cells[0]
.length. When I debug the code, I see that once in a while, reqRowsToPaint is greater than cells[0]
.length. I am not sure why that may have happened but perhaps if this case can be handled, then this issue would be resolved.

I noticed that there is a check like this for start:

        if (start > cells[CELL_ITEMID]
.length || start < 0) {
            start = 0;
        }

why not a check for end like:

        if (end > cells[CELL_ITEMID]
.length) {
            end = cells[CELL_ITEMID]
.length;
        }

I got the check on end patched to the source and compiled it. Now when I get the error condition, instead of crashing and getting an “internal error”, the table just won’t render till user scrolls a bit further down.

Which brings me to another point about the dreaded “internal error”. When users gets this error, the only way it appears to resume is to close all instances of the browser and re-open it. Just hitting refresh won’t solve it as the component tree in session is now out of sync and it won’t heal by itself. Is there any easier way to resume from an internal error like this?

Thanks,

I’ve just had this problem.

Solved by overriding the terminalError() method in the Application class and forcing a session invalidation.

  public void terminalError(Terminal.ErrorEvent event) {
    super.terminalError(event);

    close();

    WebApplicationContext context = (WebApplicationContext) getContext();
    HttpSession httpSession = context.getHttpSession();
    httpSession.invalidate();
  }

Thanks for pointing out, that the session is broken after the internal error. While developing with ?restartApplication I did not notice this problem.

Overwriting the terminalError solves this - but now the user is redirected to the start page of the application without realizing that there was an error.
How can I achive, that there is first an info to the user and after that the redirect comes?

Thank for help,
Horst