Skip to content

Instantly share code, notes, and snippets.

@tbml
Created May 2, 2018 06:46
Show Gist options
  • Save tbml/5c11317fb06a7cfc0617b203fcf75cf5 to your computer and use it in GitHub Desktop.
Save tbml/5c11317fb06a7cfc0617b203fcf75cf5 to your computer and use it in GitHub Desktop.
Possible corrupted composite method invocation
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() {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment