openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: NoSuchElementException in InstanceImpl#iterator() after upgrading openejb-core to 8.0.0-M3
Date Wed, 11 Sep 2019 10:24:37 GMT
And we are still looking into it whether we can make it go away (again).
But that isn't a guarantee that this will not cause any pains in other containers as well.
At least under heavy load. 
And yikes, that's hard to test :(

LieGrue,
strub

> Am 11.09.2019 um 11:54 schrieb Romain Manni-Bucau <rmannibucau@gmail.com>:
> 
> We got some perf enhancements about Instance so it can be visible now whereas it was
hidden before cause slower.
> 
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
> 
> 
> Le mer. 11 sept. 2019 à 11:51, Matthias Knappik <Matthias.Knappik@faktorzehn.de>
a écrit :
> Hi,
> Thank you for your response. I'll change our behavior in regards to concurrency.
> However, I would like to point out,  that the test in our project was executed thousands
of times without any problem in 7.1.0 and prior releases, while the issue is 100% reproducible
with 8.0.0-M3. So I really wonder what causes this difference.
> 
> Best Regards
> 
> Matthias Knappik
> 
> Senior Developer
> 
> Faktor Zehn GmbH
> Friedenheimer Brücke 21
> 80639 München
> 
> Phone   +49 89 520311-683
> Fax     +49 89 520311-8683
> Mobile  +49 151 582 56644
> 
> Matthias.Knappik@faktorzehn.de
> http://www.ConVista.com
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg <struberg@yahoo.de>
> Gesendet: Mittwoch, 11. September 2019 10:02
> An: openwebbeans-user <user@openwebbeans.apache.org>
> Betreff: Re: NoSuchElementException in InstanceImpl#iterator() after upgrading openejb-core
to 8.0.0-M3
> 
> To be honest, I'm not sure this is really a bug.
> 
> a.) the CDI architecture guide basically says that whenever you use @ApplicationScoped
in a multi-threaded scenario then you have to deal with concurrency yourself. After all those
are not @Stateless EJBs...
> b.) The Instance definition also doesn't define that Instance is thread safe.
> 
> So even if WE fix it, it is not guaranteed that you will be blowing up on many different
containers. As it's not defined by the spec.
> 
> LieGrue,
> strub
> 
> > Am 11.09.2019 um 09:43 schrieb Romain Manni-Bucau <rmannibucau@gmail.com>:
> >
> > Hi Matthias,
> >
> > I don't think it is a regression by itself since this is the behavior since a long
time but it is clearly a bug.
> > Will work on it very soon.
> >
> > Romain Manni-Bucau
> > @rmannibucau |  Blog | Old Blog | Github | LinkedIn | Book
> >
> >
> > Le mer. 11 sept. 2019 à 09:24, Matthias Knappik <Matthias.Knappik@faktorzehn.de>
a écrit :
> > Hi,
> >
> > after upgrading the openejb-core dependency in one of our projects from 7.1.0 to
8.0.0-M3 in order to support java 11, one of our tests was failing due to an NoSuchElementException
in org.apache.webbeans.inject.instance.InstanceImpl#iterator().
> >
> > Our last executed code is:
> >
> >     private Stream<PolicyPermissionService> permissionServices() {
> >
> >         return StreamSupport.stream(permissionServices.spliterator(), false);
> >
> >     }
> >
> >
> >
> > A little bit of research showed, that this method is being executed in parallel
by an batch job, which explains the Exception: InstanceImpl#iterator() seems not to be threadsafe.
As a consequence, removeFirst() gets executed, even if there is no Element in the List.
> >
> >
> >
> > A quick fix for us was to put the call into an synchronized block:
> >
> >     private synchronized Stream<PolicyPermissionService> permissionServices()
{
> >
> >         return StreamSupport.stream(permissionServices.spliterator(), false);
> >
> >     }
> >
> >
> >
> > However, I think it should not be required to do so and it was working fine in 7.1.0.
> >
> >
> >
> > Stacktrace:
> >
> > java.util.NoSuchElementException
> >
> >         at java.util.LinkedList.removeFirst(LinkedList.java:270)
> >
> >         at java.util.LinkedList.pop(LinkedList.java:801)
> >
> >         at org.apache.webbeans.context.creational.CreationalContextImpl.removeInjectionPoint(CreationalContextImpl.java:142)
> >
> >         at org.apache.webbeans.inject.instance.InstanceImpl.iterator(InstanceImpl.java:256)
> >
> >         at java.lang.Iterable.spliterator(Iterable.java:101)
> >
> >         at de.faktorzehn.ipm.core.services.user.PolicyPermissionServiceProvider.permissionServices(PolicyPermissionServiceProvider.java:46)
> >
> >         at de.faktorzehn.ipm.core.services.user.PolicyPermissionServiceProvider.getPermissionService(PolicyPermissionServiceProvider.java:38)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository.hasReadPermission(JpaPolicyRepository.java:383)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository.lambda$readPermissionFor$0(JpaPolicyRepository.java:110)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository.internalGetPolicy(JpaPolicyRepository.java:121)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository.getPolicy(JpaPolicyRepository.java:106)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.webbeans.intercept.AbstractInvocationContext.directProceed(AbstractInvocationContext.java:113)
> >
> >         at org.apache.webbeans.intercept.AbstractInvocationContext.proceed(AbstractInvocationContext.java:106)
> >
> >         at org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:78)
> >
> >         at org.apache.openejb.cdi.transactional.InterceptorBase.intercept(InterceptorBase.java:67)
> >
> >         at org.apache.openejb.cdi.transactional.RequiredInterceptor.intercept(RequiredInterceptor.java:35)
> >
> >         at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.webbeans.component.InterceptorBean.intercept(InterceptorBean.java:136)
> >
> >         at org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:65)
> >
> >         at org.apache.webbeans.intercept.DefaultInterceptorHandler.invoke(DefaultInterceptorHandler.java:139)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository$$OwbInterceptProxy1.getPolicy(de/faktorzehn/ipm/core/services/persistence/JpaPolicyRepository.java)
> >
> >         at de.faktorzehn.ipm.core.services.persistence.JpaPolicyRepository$$OwbNormalScopeProxy1.getPolicy(de/faktorzehn/ipm/core/services/persistence/JpaPolicyRepository.java)
> >
> >         at de.faktorzehn.ipm.core.batch.services.EditPolicyService.getPolicy(EditPolicyService.java:214)
> >
> >         at de.faktorzehn.ipm.core.batch.services.EditPolicyService.lambda$editPolicy$2(EditPolicyService.java:89)
> >
> >         at de.faktorzehn.ipm.core.batch.services.FailCheckedEditing.withPolicy(FailCheckedEditing.java:236)
> >
> >         at de.faktorzehn.ipm.core.batch.services.EditPolicyService.editPolicy(EditPolicyService.java:89)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.webbeans.intercept.AbstractInvocationContext.directProceed(AbstractInvocationContext.java:113)
> >
> >         at org.apache.webbeans.intercept.AbstractInvocationContext.proceed(AbstractInvocationContext.java:106)
> >
> >         at org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:78)
> >
> >         at org.apache.openejb.cdi.transactional.InterceptorBase.intercept(InterceptorBase.java:67)
> >
> >         at org.apache.openejb.cdi.transactional.RequiredInterceptor.intercept(RequiredInterceptor.java:35)
> >
> >         at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.webbeans.component.InterceptorBean.intercept(InterceptorBean.java:136)
> >
> >         at org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:65)
> >
> >         at org.apache.webbeans.intercept.DefaultInterceptorHandler.invoke(DefaultInterceptorHandler.java:139)
> >
> >         at de.faktorzehn.ipm.sample.batch.hranpassung.HrAnpassungService$$OwbInterceptProxy1.editPolicy(de/faktorzehn/ipm/sample/batch/hranpassung/HrAnpassungService.java)
> >
> >         at de.faktorzehn.ipm.sample.batch.hranpassung.HrAnpassungService$$OwbNormalScopeProxy0.editPolicy(de/faktorzehn/ipm/sample/batch/hranpassung/HrAnpassungService.java)
> >
> >         at de.faktorzehn.ipm.core.batch.ParameterizedPolicyWriter.lambda$doWriteItems$0(ParameterizedPolicyWriter.java:59)
> >
> >         at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
> >
> >         at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
> >
> >         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
> >
> >         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
> >
> >         at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
> >
> >         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> >
> >         at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
> >
> >         at de.faktorzehn.ipm.core.batch.ParameterizedPolicyWriter.doWriteItems(ParameterizedPolicyWriter.java:60)
> >
> >         at org.apache.batchee.extras.typed.TypedItemWriter.writeItems(TypedItemWriter.java:35)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.batchee.container.proxy.BatchProxyInvocationHandler.invoke(BatchProxyInvocationHandler.java:55)
> >
> >         at com.sun.proxy.$Proxy204.writeItems(Unknown Source)
> >
> >         at org.apache.batchee.container.impl.controller.chunk.ChunkStepController.writeChunk(ChunkStepController.java:433)
> >
> >         at org.apache.batchee.container.impl.controller.chunk.ChunkStepController.invokeChunk(ChunkStepController.java:579)
> >
> >         at org.apache.batchee.container.impl.controller.chunk.ChunkStepController.invokeCoreStep(ChunkStepController.java:732)
> >
> >         at org.apache.batchee.container.impl.controller.BaseStepController.execute(BaseStepController.java:157)
> >
> >         at org.apache.batchee.container.impl.controller.ExecutionTransitioner.doExecutionLoop(ExecutionTransitioner.java:106)
> >
> >         at org.apache.batchee.container.impl.controller.JobThreadRootController.originateExecutionOnThread(JobThreadRootController.java:110)
> >
> >         at org.apache.batchee.container.util.BatchWorkUnit.run(BatchWorkUnit.java:62)
> >
> >         at org.apache.batchee.tools.services.thread.ThreadExecutorEjb.executeTask(ThreadExecutorEjb.java:51)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:205)
> >
> >         at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:186)
> >
> >         at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:191)
> >
> >         at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:102)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> >
> >         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >
> >         at java.lang.reflect.Method.invoke(Method.java:498)
> >
> >         at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:205)
> >
> >         at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:186)
> >
> >         at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:85)
> >
> >         at org.apache.openejb.core.singleton.SingletonContainer._invoke(SingletonContainer.java:272)
> >
> >         at org.apache.openejb.core.singleton.SingletonContainer.invoke(SingletonContainer.java:221)
> >
> >         at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:265)
> >
> >         at org.apache.openejb.core.ivm.EjbObjectProxyHandler$1.call(EjbObjectProxyHandler.java:252)
> >
> >         at org.apache.openejb.threads.task.CUTask.invoke(CUTask.java:100)
> >
> >         at org.apache.openejb.threads.task.CUCallable.call(CUCallable.java:31)
> >
> >         at org.apache.openejb.async.AsynchronousPool$AsynchronousCall.call(AsynchronousPool.java:113)
> >
> >         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> >
> >         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> >
> >         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> >
> >         at java.lang.Thread.run(Thread.java:748)
> >
> >
> >
> > Best Regards
> >
> >
> >
> >
> > Matthias Knappik
> > Senior Developer
> >
> > Faktor Zehn GmbH
> > Friedenheimer Brücke 21
> > 80639 München
> >
> > Phone    +49 89 520311-683
> > Fax        +49 89 520311-8683
> > Mobile    +49 151 582 56644
> >
> > Matthias.Knappik@faktorzehn.de
> > http://www.ConVista.com
> >
> >
> >
> > Faktor Zehn GmbH       Sitz der Gesellschaft: München  Registernummer: HRB 242535
Registergericht: Amtsgericht München
> > Geschaeftsfuehrung: Dr. Florian Schwandt, Joerg Renger
> 
> 
> 
> ----------------------------------------------------------------------------------
> 
> Faktor Zehn GmbH      Sitz der Gesellschaft: Muenchen   Registernummer: HRB 242535 Registergericht:
Amtsgericht Muenchen
> Geschaeftsfuehrung: Dr. Florian Schwandt, Joerg Renger
> 


Mime
View raw message