polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [09/13] polygene-java git commit: issue report with composite method invocation
Date Fri, 04 May 2018 02:22:16 GMT
issue report with composite method invocation


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/fe8ed3e0
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/fe8ed3e0
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/fe8ed3e0

Branch: refs/heads/develop
Commit: fe8ed3e01bd81f1fd4cc921e1277c6c947f2c343
Parents: 77b6806
Author: tbml <tibor.mlynarik@adleritech.com>
Authored: Wed May 2 08:15:41 2018 +0200
Committer: tbml <tibor.mlynarik@adleritech.com>
Committed: Wed May 2 08:15:41 2018 +0200

----------------------------------------------------------------------
 .../CompositeMethodInvocationTest.java          | 55 ++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/fe8ed3e0/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeMethodInvocationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeMethodInvocationTest.java
b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeMethodInvocationTest.java
new file mode 100644
index 0000000..44d4ea3
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/polygene/runtime/composite/CompositeMethodInvocationTest.java
@@ -0,0 +1,55 @@
+package org.apache.polygene.runtime.composite;
+
+import org.apache.polygene.api.injection.scope.Service;
+import org.apache.polygene.api.mixin.Mixins;
+import org.apache.polygene.api.service.ServiceComposite;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.junit.jupiter.api.Test;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class CompositeMethodInvocationTest extends AbstractPolygeneTest {
+
+    @Service
+    MyService srv;
+
+    /**
+     * To correct, change instance pool type in CompositeMethodModel
+     * AtomicInstancePool -> SynchronizedCompositeMethodInstancePool
+     */
+    @Test
+    public void corruptedMethodInvocation() throws InterruptedException {
+        srv.dummy(); // to avoid concurrent activation (it can have own issues)
+
+        ExecutorService exe = Executors.newFixedThreadPool(10);
+        for (int i = 0; i < 10; i++) {
+            exe.execute(() -> {
+                while (true) {
+                    srv.dummy();
+                }
+            });
+        }
+        exe.awaitTermination(10, TimeUnit.MINUTES);
+    }
+
+    @Override
+    public void assemble(ModuleAssembly module) throws AssemblyException {
+        module.services(MyService.class);
+    }
+
+    @Mixins(Impl.class)
+    public interface MyService extends ServiceComposite {
+        void dummy();
+    }
+
+    public abstract static class Impl implements MyService {
+        @Override
+        public void dummy() {
+        }
+    }
+
+}


Mime
View raw message