cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Error when setting dynamic attribute for entity through REST API #3250

Closed imorenov94 closed 2 years ago

imorenov94 commented 3 years ago

Environment

CUBA Platform version: 7.2.16 CUBA Studio plugin version: 15.6-211 IntelliJ version: IntelliJ IDEA 2021.2.3 (Ultimate Edition)

Description of the bug or enhancement

See the forum question

Steps:

  1. Create a new project
  2. Create a new Entity (TestEntity) with the one attribute "name" and editor/browser screens
  3. Add REST API addon
  4. Run the application
  5. Navigate to Administration ->Dynamic Attributes tab
  6. Create a new category with the Entity type from step 2
  7. Create the attribute:
    • Enter the following values on General tab: name: testAttr Type: Enumeration Enumeration: a,b,c
    • Add editor and browser screens of entity in target screens on the Visibility tab
  8. Open postman
  9. Get token through GET request http://localhost:8080/app/rest/v2/oauth/token?grant_type=password&username=admin&password=admin
  10. Send POST request for created Entity to the current endpoint http://localhost:8080/app/rest/v2/entities/{entityName} with next body: { "name": "test", "+newAttr": [ "a","b","c" ] }
  11. Open browser.Screen for created entity and try to change enum values Expected behavior: Values should not be duplicated and should be available for editing from UI Actual behavior: Values defined from REST have been duplicated, and if we try to change them so then we will be faced with the error:
    
    11:26:04.685 ERROR com.haulmont.cuba.web.log.AppLog        - Exception in com.haulmont.cuba.web.widgets.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:157) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1580) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329) ~[cuba-web-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215) ~[cuba-web-7.2.16.jar:7.2.16]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[servlet-api.jar:4.0.FR]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:9.0.38]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-websocket.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:9.0.38]
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108) ~[spring-web-5.2.16.RELEASE.jar:5.2.16.RELEASE]
    at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74) ~[spring-web-5.2.16.RELEASE.jar:5.2.16.RELEASE]
    at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93) ~[cuba-web-7.2.16.jar:7.2.16]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[catalina.jar:9.0.38]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[catalina.jar:9.0.38]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[catalina.jar:9.0.38]
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690) ~[catalina.jar:9.0.38]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[catalina.jar:9.0.38]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[catalina.jar:9.0.38]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) ~[tomcat-coyote.jar:9.0.38]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-coyote.jar:9.0.38]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-coyote.jar:9.0.38]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) ~[tomcat-coyote.jar:9.0.38]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-coyote.jar:9.0.38]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-util.jar:9.0.38]
    at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
    Caused by: java.lang.reflect.InvocationTargetException: null
    at jdk.internal.reflect.GeneratedMethodAccessor215.invoke(Unknown Source) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    ... 38 common frames omitted
    Caused by: java.lang.IllegalStateException: Duplicate key Read (attempted merging values Read and Read)
    at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133) ~[na:na]
    at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180) ~[na:na]
    at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
    at com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.initValues(ListEditorPopupWindow.java:153) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.init(ListEditorPopupWindow.java:133) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.components.AbstractWindow.init(AbstractWindow.java:104) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.bali.events.EventHub.publish(EventHub.java:170) ~[cuba-global-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.screen.Screen.fireEvent(Screen.java:128) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:60) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.sys.WebScreens.createScreen(WebScreens.java:262) ~[cuba-web-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.sys.WebScreens.create(WebScreens.java:179) ~[cuba-web-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.components.listeditor.ListEditorDelegateImpl.openEditor(ListEditorDelegateImpl.java:192) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.gui.components.listeditor.ListEditorDelegateImpl.lambda$init$0(ListEditorDelegateImpl.java:113) ~[cuba-gui-7.2.16.jar:7.2.16]
    at com.haulmont.bali.events.EventHub.publish(EventHub.java:170) ~[cuba-global-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.gui.components.WebAbstractComponent.publish(WebAbstractComponent.java:100) ~[cuba-web-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:70) ~[cuba-web-7.2.16.jar:7.2.16]
    at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76) ~[cuba-web-widgets-7.2.16.jar:na]
    at com.vaadin.ui.Button$1.click(Button.java:57) ~[vaadin-server-8.9.2-27-cuba.jar:8.9.2-27-cuba]
    ... 42 common frames omitted
beatle01 commented 2 years ago

Hi - is there any planning regarding this bug? We are running into problems with our install base as a result of it and we do not have an alternative - no workaround possible.