You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by "Andi Huber (JIRA)" <ji...@apache.org> on 2018/01/26 08:07:01 UTC

[jira] [Comment Edited] (ISIS-1852) Iterating over query result list with parallelStream produces next exception

    [ https://issues.apache.org/jira/browse/ISIS-1852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16340377#comment-16340377 ] 

Andi Huber edited comment on ISIS-1852 at 1/26/18 8:06 AM:
-----------------------------------------------------------

Thanks for reporting this.

Internal Note:
Investigating the problem, there might be need of InheritableThreadLocal [1] instead of ThreadLocal, in our implementation of ServiceInstantiator. 

Reason: we initialize proxy objects on thread A, which are later (optionally) accessed on child-threads of A. We need to share the service variable that is stored in ThreadLocal (of A) to be accessible on child-threads of A.

[1] https://docs.oracle.com/javase/8/docs/api/java/lang/InheritableThreadLocal.html

 


was (Author: hobrom):
Thanks for reporting this.

Internal Note:
Investigating the problem (and definitely not fully understanding what's going on), there might be need of InheritableThreadLocal instead of ThreadLocal, in our implementation of ServiceInstantiator. But at the time being, this is just a wild guess.

[1] https://docs.oracle.com/javase/8/docs/api/java/lang/InheritableThreadLocal.html|https://docs.oracle.com/javase/8/docs/api/java/lang/InheritableThreadLocal.html

 

> Iterating over query result list with parallelStream produces next exception
> ----------------------------------------------------------------------------
>
>                 Key: ISIS-1852
>                 URL: https://issues.apache.org/jira/browse/ISIS-1852
>             Project: Isis
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.15.1
>            Reporter: Vladimir Nisevic
>            Priority: Major
>
> Given the the result from database, e.g.
> {code:java}
> final List<MobileDevice> devices = repositoryService.allInstances(MobileDevice.class);{code}
> When I iterate over list with parallelStream
> {code:java}
> filteredDevices.parallelStream().forEach(mobileDevice -> {
> // my stuff here
> });{code}
> Then I get this exception
> {code:java}
> ... 134 more
> Caused by: java.lang.IllegalStateException: No service of type class org.apache.isis.core.runtime.services.metrics.MetricsServiceDefault is available on this 
> at org.apache.isis.core.runtime.services.ServiceInstantiator$2.invoke(ServiceInstantiator.java:217)
> at org.apache.isis.core.runtime.services.metrics.MetricsServiceDefault_$$_jvstad5_7.postLoad(MetricsServiceDefault_$$_jvstad5_7.java)
> at org.datanucleus.api.jdo.JDOCallbackHandler.postLoad(JDOCallbackHandler.java:305)
> at org.datanucleus.state.StateManagerImpl.postLoad(StateManagerImpl.java:4443)
> at org.datanucleus.state.StateManagerImpl.initialiseForCachedPC(StateManagerImpl.java:645)
> at org.apache.isis.objectstore.jdo.datanucleus.JDOStateManagerForIsis.initialiseForCachedPC(JDOStateManagerForIsis.java:112)
> at org.datanucleus.state.ObjectProviderFactoryImpl.newForCachedPC(ObjectProviderFactoryImpl.java:280)
> at org.datanucleus.ExecutionContextImpl.getObjectFromLevel2Cache(ExecutionContextImpl.java:5210)
> at org.datanucleus.ExecutionContextImpl.getObjectFromCache(ExecutionContextImpl.java:5101)
> at org.datanucleus.ExecutionContextImpl.findObject(ExecutionContextImpl.java:3048)
> at org.datanucleus.store.rdbms.query.PersistentClassROF.getObjectForDatastoreId(PersistentClassROF.java:460)
> at org.datanucleus.store.rdbms.query.PersistentClassROF.getObject(PersistentClassROF.java:385)
> at org.datanucleus.store.rdbms.scostore.CollectionStoreIterator.<init>(CollectionStoreIterator.java:100)
> at org.datanucleus.store.rdbms.scostore.FKSetStore.iterator(FKSetStore.java:1080)
> at org.datanucleus.store.types.wrappers.backed.Collection.loadFromStore(Collection.java:374)
> at org.datanucleus.store.types.java8.wrappers.backed.Collection.stream(Collection.java:70)
> at a1.guidedselling.offer.hardware.MobileDevice.referenceNextDevicePriceForTarifWithoutService(MobileDevice.java:195)
> at a1.guidedselling.templates.OfferTemplatesRepository.lambda$offerTemplatesFor$1(OfferTemplatesRepository.java:102)
> at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
> at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
> at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
> at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
> at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
> at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
> at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
> at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
> at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157){code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)