berndhopp / guice

guice-integration for the vaadin-framework
https://vaadin.com/directory#!addon/guice-vaadin-integration
10 stars 7 forks source link

Java 9+ ConcurrentModification in UIScope #18

Closed meiko closed 4 years ago

meiko commented 5 years ago

With Java 9+ a ConcurrentModification was thrown when the injection of ViewScope Views occured the first time. The reason is the changed behavior of HashMap::computeIfAbsent. Now a ConcurrentModification is thrown, if the map is changed in the mappingfunction. This pull request seems to fix the problem: https://github.com/berndhopp/guice/pull/17

`SEVERE: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, java.util.ConcurrentModificationException at de.test.views.ProdView.class(ProdView.java:15) while locating de.test.views.ProdView

1 error at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226) at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053) at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086) at com.vaadin.guice.server.ViewProviderBase.getView(ViewProviderBase.java:22) at com.vaadin.guice.server.GuiceViewProvider.createView(GuiceViewProvider.java:95) at com.vaadin.guice.server.GuiceViewProvider.lambda$getView$5(GuiceViewProvider.java:87) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133) at com.vaadin.guice.server.GuiceViewProvider.getView(GuiceViewProvider.java:87) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:652) at de.test.views.DefaultView.lambda$new$91da45c0$1(DefaultView.java:18) 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.event.ListenerMethod.receiveEvent(ListenerMethod.java:499) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:273) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:237) at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1014) at com.vaadin.ui.Button.fireClick(Button.java:384) 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:155) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:116) at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:445) at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:410) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274) at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1601) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:445) at javax.servlet.http.HttpServlet.service(HttpServlet.java:791) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at ...`

meiko commented 5 years ago

I tried to inject dependencies into CustomComponents used in templates of another Component - by using a custom Design.ComponentFactory. I will give a minimal example later.

berndhopp commented 4 years ago

should be fixed in 2019.1-vaadin14

johanneshayry commented 2 years ago

should be fixed in 2019.1-vaadin14

Any chance getting this PR to Vaadin 8 version too? I'm facing this issue now when migrating from Java 8 to 17.

berndhopp commented 2 years ago

should be fixed in 2019.1-vaadin14

Any chance getting this PR to Vaadin 8 version too? I'm facing this issue now when migrating from Java 8 to 17. V8 is unmaintained, but if you send me a PR I will have a look

johanneshayry commented 2 years ago

Thanks for replying. I'll put it to my todo list.