IndexOutOfBoundsException: Index: 8, Size: 7

Hi,

if I search via full-text filter I get this error:

This is the exception stack:

java.lang.IndexOutOfBoundsException: Index: 8, Size: 7
at java.base/java.util.LinkedList.checkPositionIndex(LinkedList.java:564)
at java.base/java.util.LinkedList.add(LinkedList.java:511)
at com.vaadin.ui.AbstractOrderedLayout.addComponent(AbstractOrderedLayout.java:146)
at com.haulmont.cuba.web.gui.components.WebAbstractActionsHolderComponent.addAction(WebAbstractActionsHolderComponent.java:207)
at com.haulmont.cuba.web.gui.components.WebAbstractActionsHolderComponent.addAction(WebAbstractActionsHolderComponent.java:178)
at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.initFtsDetailsAction(FilterDelegateImpl.java:1850)
at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.applyFts(FilterDelegateImpl.java:1828)
at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl$1.actionPerform(FilterDelegateImpl.java:405)
at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:67)
at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)
at com.vaadin.ui.Button$1.click(Button.java:57)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

For reproducing this error you can:

  1. check full-text search checkbox
  2. click on one row
  3. write a string in search box
  4. click search

The exception occurs when the program tries to add Full-text search details in context menu.

Thanks to all for the help.

Hi.

Could you clarify please which platform version do yo use?

Regards,
Nadezhda.

Hi,

platform version is: 7.2.13

Regards
Nico

Unfortunately, we cannot reproduce the problem. We will be able to help you if you send us a small sample project along with a reproduction scenario that demonstrates the issue.

Regards,
Nadezhda.

Hi,

I created a small project for reproduce the problem ftsproblem.zip (103.0 KB) . The problem is thrown when are enabled attachment support and fts. For reproduce the problem:

  • Open Persons screen
  • Click on the second record
  • Enable Full-Text Search checkbox
  • Write “v” in fiter
  • Click Search

Thanks for your help

Thank you for the example, the issue was reproduced. We have created Github issue.

Regards,
Nadezhda.

Ok, thanks for support.

Anyway I found a workaround that could be useful for someone:

I add this handler to every browser screen where is enabled attachment support

// Workaround to avoid index out of range see: https://forum.cuba-platform.com/t/indexoutofboundsexception-index-8-size-7/15331
    @Install(to = "filter", subject = "afterFilterAppliedHandler")
    protected void filterAfterFilterAppliedHandler() {
        personsTable.removeAction("attachment");
    }

After an other investigation I found the true problem… In class WebAbstractActionsHolderComponent in this part:

int visibleActionsIndex = 0;
        int i = 0;
        while (i < index && i < actionList.size()) {
            if (StringUtils.isNotEmpty(actionList.get(i).getCaption())) {
                visibleActionsIndex++;
            }

            i++;
        }

the check of action visibility is done using caption. In my case the action attachment didn’t have caption and this caused the exception. For solving this problem is enough to set caption on all the visibile action in table.

I hope this can help others.

BR

1 Like