Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 0cb52e7

Browse files
committed
Merge remote-tracking branch 'origin/tbml/invoke-issue' into develop
2 parents 2a643f5 + fe8ed3e commit 0cb52e7

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}

0 commit comments

Comments
 (0)