openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: NoSuchElementException in InstanceImpl#iterator() after upgrading openejb-core to 8.0.0-M3
Date Wed, 11 Sep 2019 07:43:25 GMT
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 <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


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
>

Mime
View raw message