This repository was archived by the owner on May 12, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
core/runtime/src/test/java/org/apache/polygene/runtime/composite Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .apache .polygene .runtime .composite ;
2+
3+ import org .apache .polygene .api .injection .scope .Service ;
4+ import org .apache .polygene .api .mixin .Mixins ;
5+ import org .apache .polygene .api .service .ServiceComposite ;
6+ import org .apache .polygene .bootstrap .AssemblyException ;
7+ import org .apache .polygene .bootstrap .ModuleAssembly ;
8+ import org .apache .polygene .test .AbstractPolygeneTest ;
9+ import org .junit .jupiter .api .Test ;
10+
11+ import java .util .concurrent .ExecutorService ;
12+ import java .util .concurrent .Executors ;
13+ import java .util .concurrent .TimeUnit ;
14+
15+ public class CompositeMethodInvocationTest extends AbstractPolygeneTest {
16+
17+ @ Service
18+ MyService srv ;
19+
20+ /**
21+ * To correct, change instance pool type in CompositeMethodModel
22+ * AtomicInstancePool -> SynchronizedCompositeMethodInstancePool
23+ */
24+ @ Test
25+ public void corruptedMethodInvocation () throws InterruptedException {
26+ srv .dummy (); // to avoid concurrent activation (it can have own issues)
27+
28+ ExecutorService exe = Executors .newFixedThreadPool (10 );
29+ for (int i = 0 ; i < 10 ; i ++) {
30+ exe .execute (() -> {
31+ while (true ) {
32+ srv .dummy ();
33+ }
34+ });
35+ }
36+ exe .awaitTermination (10 , TimeUnit .MINUTES );
37+ }
38+
39+ @ Override
40+ public void assemble (ModuleAssembly module ) throws AssemblyException {
41+ module .services (MyService .class );
42+ }
43+
44+ @ Mixins (Impl .class )
45+ public interface MyService extends ServiceComposite {
46+ void dummy ();
47+ }
48+
49+ public abstract static class Impl implements MyService {
50+ @ Override
51+ public void dummy () {
52+ }
53+ }
54+
55+ }
You can’t perform that action at this time.
0 commit comments