mariodavid / cuba-component-attachable

CUBA component that lets you add attachments to any entity
Apache License 2.0
7 stars 2 forks source link

Component conflicts with Add To Set Folder Functionality #17

Open adhawan325 opened 6 years ago

adhawan325 commented 6 years ago

Hi Mario -

Thank you for the great work on this component. I have run into an issue with this component that I would like to bring to your attention.

In my project, I use this component on a Table alongside the "Add to Set" (https://doc.cuba-platform.com/manual-6.9/folders_pane.html) functionality of the platform. In this scenario, when I select a single row in the table and hit "Search" on the filters panel, I receive an ArrayIndexOutOfBounds Exception. It is important to note that no exception is received when a row is not selected and the Search button is clicked.

In tracing this exception, I have found that the issue exists on this line: https://github.com/cuba-platform/cuba/blob/2a3d0a97ba475ce31c00e018161575d623614e85/modules/gui/src/com/haulmont/cuba/gui/components/filter/FilterDelegateImpl.java#L1967

The platform code is looking for the size of the "actions" array on the table and attempting to add the "Add To Set" action to that array per this line of code:

https://github.com/cuba-platform/cuba/blob/e70a3bb1660e836fe7e6313d8825ec350796d1f7/modules/web/src/com/haulmont/cuba/web/gui/components/WebAbstractActionsHolderComponent.java#L109

In my scenario, the following actions exist on the Table: Create create (0) Edit edit (1) Remove remove (2) System Information showSystemInfo (3) attachment (4) Add to set filter.addToSet (5)

The Exception I receive has the following text; IndexOutOfBoundsException: Index: 5, Size: 4

I suspect that this is because somehow, the component's action is not registering properly (I am not too sure about this).

I am interested in your thoughts on how I can fix this. I attempted to look through the component's code and wasn't able to readily identify the issue. My hope is that you have an insight that can help resolve this issue for me.

My suspicion is that moving the code from init to ready in this block should resolve the problem:

https://github.com/mariodavid/cuba-component-attachable/blob/efd7727db88fcc42365d8130ac23fea0a5897c60/modules/web/src/de/diedavids/cuba/attachable/web/annotationexecutor/WithAttachmentsBrowseAnnotationExecutor.groovy#L40

For your reference, the full stack trace is listed below:

2018-09-10 08:30:26.520 ERROR [http-nio-8080-exec-13] com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaButton: com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:160) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:444) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:409) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361) [vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:312) [cuba-web-6.9.5.jar:6.9.5] at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:203) [cuba-web-6.9.5.jar:6.9.5] at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [servlet-api.jar:na] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23] at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107) [spring-web-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73) [spring-web-4.3.14.RELEASE.jar:4.3.14.RELEASE] at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:107) [cuba-web-6.9.5.jar:6.9.5] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.23] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.23] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.23] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.23] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.23] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) [catalina.jar:8.5.23] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.23] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.23] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-coyote.jar:8.5.23] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.23] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.23] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-coyote.jar:8.5.23] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.23] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.23] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181] Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181] at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] ... 38 common frames omitted Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in com.haulmont.cuba.web.gui.components.WebButton$$Lambda$162/696634900 failed. at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:530) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.vaadin.ui.Button.fireClick(Button.java:377) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.haulmont.cuba.web.toolkit.ui.CubaButton.fireClick(CubaButton.java:54) ~[cuba-web-6.9.5.jar:6.9.5] at com.vaadin.ui.Button$1.click(Button.java:54) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] ... 43 common frames omitted Caused by: java.lang.IndexOutOfBoundsException: Index: 5, Size: 4 at java.util.LinkedList.checkPositionIndex(LinkedList.java:560) ~[na:1.8.0_181] at java.util.LinkedList.add(LinkedList.java:507) ~[na:1.8.0_181] at com.vaadin.ui.AbstractOrderedLayout.addComponent(AbstractOrderedLayout.java:148) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11] at com.haulmont.cuba.web.gui.components.WebAbstractActionsHolderComponent.addAction(WebAbstractActionsHolderComponent.java:137) ~[cuba-web-6.9.5.jar:6.9.5] at com.haulmont.cuba.web.gui.components.WebAbstractActionsHolderComponent.addAction(WebAbstractActionsHolderComponent.java:103) ~[cuba-web-6.9.5.jar:6.9.5] at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.fillTableActions(FilterDelegateImpl.java:1909) ~[cuba-gui-6.9.5.jar:6.9.5] at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.setFilterActionsEnabled(FilterDelegateImpl.java:678) ~[cuba-gui-6.9.5.jar:6.9.5] at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.apply(FilterDelegateImpl.java:1480) ~[cuba-gui-6.9.5.jar:6.9.5] at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl$1.actionPerform(FilterDelegateImpl.java:288) ~[cuba-gui-6.9.5.jar:6.9.5] at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:46) ~[cuba-web-6.9.5.jar:6.9.5] at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:38) ~[cuba-web-6.9.5.jar:6.9.5] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181] at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) ~[vaadin-server-7.7.13.cuba.11.jar:7.7.13.cuba.11]

mariodavid commented 6 years ago

Hi,

Thanks for the report. I'll take a look shortly.

Bye Mario

adhawan325 commented 6 years ago

@mariodavid - Hey Mario - any thoughts?

mariodavid commented 6 years ago

hi,

no I did not take a look yet. But still: the exception stacktrace you gave me does not seem to contain all relevant information. The Exception in com.haulmont.cuba.web.toolkit.ui.CubaButton is just a downstream error. Where exactly does the ArrayIndexOutOfBoundsException happens?