[Demonstration 1]

[Buggy Method]
public <T> T createProxy(Class<T> serviceInterface, final Class<? extends Router> routerType, Duration timeout) {
    serviceDefinition = serviceRegistry.registerInterface(serviceInterface);
    return Reflection.newProxy(serviceInterface, new InvocationHandler() {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            try {
                // fetch the service definition by the method name
                Router router = routerFactory.getRouter(routerType);
                Object data = method.getParameterCount() != 0 ? args[0] : null;
                Message reqMsg = Message.withData(data).header(ServiceHeaders.SERVICE_REQUEST, serviceDefinition.serviceName()).header(ServiceHeaders.METHOD, method.getName()).build();
                Optional<ServiceInstance> optionalServiceInstance = router.route(reqMsg);
                if (optionalServiceInstance.isPresent()) {
                    ServiceInstance serviceInstance = optionalServiceInstance.get();
                    CompletableFuture<?> resultFuture = (CompletableFuture<?>) serviceInstance.invoke(reqMsg);
                    if (method.getReturnType().equals(Void.TYPE)) {
                        return CompletableFuture.completedFuture(Void.TYPE);
                    } else {
                        return timeoutAfter(resultFuture, timeout);
                    }
                } else {
                    LOGGER.error("Failed  to invoke service, No reachable member with such service definition [{}], args [{}]", serviceDefinition, args);
                    throw new IllegalStateException("No reachable member with such service: " + method.getName());
                }
            } catch (Throwable ex) {
                LOGGER.error("Failed  to invoke service, No reachable member with such service method [{}], args [{}], error [{}]", method, args, ex);
                throw new IllegalStateException("No reachable member with such service: " + method.getName());
            }
        }

        public CompletableFuture<?> timeoutAfter(final CompletableFuture<?> resultFuture, Duration timeout) {
            final CompletableFuture<Class<Void>> timeoutFuture = new CompletableFuture<>();
            // schedule to terminate the target goal in future in case it was not done yet
            final ScheduledFuture<?> scheduledEvent = delayer.schedule(() -> {
                // by this time the target goal should have finished.
                if (!resultFuture.isDone()) {
                    // target goal not finished in time so cancel it with timeout.
                    resultFuture.completeExceptionally(new TimeoutException("expecting response reached timeout!"));
                }
            }, timeout.toMillis(), TimeUnit.MILLISECONDS);
            // cancel the timeout in case target goal did finish on time
            resultFuture.thenRun(() -> {
                if (resultFuture.isDone()) {
                    if (!scheduledEvent.isDone()) {
                        scheduledEvent.cancel(false);
                    }
                    timeoutFuture.complete(Void.TYPE);
                }
            });
            return resultFuture;
        }
    });
}

[Buggy Hunk]
serviceDefinition = serviceRegistry.registerInterface(serviceInterface);

[Patch]
ServiceDefinition serviceDefinition = serviceRegistry.registerInterface(serviceInterface);

[Demonstration 2]

[Buggy Method]
private static void fireAccept(Map<Role, AssrtEState> P, Map<Role, Map<Role, AssrtCoreESend>> Q, //Map<Role, Map<AssrtDataTypeVar, AssrtArithFormula>> R,
Map<Role, Set<AssrtDataTypeVar>> K, Map<Role, AssrtFormulaHolder> F, Role self, AssrtEAccept ea, AssrtEState succ) {
    P.put(self, succ);
    Q.get(self).put(ea.peer, null);
    AssrtERequest m = ((AssrtCoreEPendingRequest) Q.get(ea.peer).put(self, null)).getMessage();
    // FIXME: core
    inputUpdateKF(null, K, F, self, (AssrtCoreEAction) ea, m);
    //outputUpdateKF(K, F, self, ea);
}

[Buggy Hunk]
inputUpdateKF(null, K, F, self, (AssrtCoreEAction) ea, m);  // FIXME: core

[Patch]
inputUpdateKF(null, K, F, self, (AssrtCoreEAction) ea, m, succ);  // FIXME: core

[Demonstration 3]

[Buggy Method]
static Entry fromProto(Testing.File proto) {
    FileHeader header = new FileHeader(proto.getName(), Hashing.md5().hashBytes(proto.getContents().toByteArray()), proto.getContents().size(), proto.getMeta());
    return new Entry(proto.getName(), header, proto.getContents());
}

[Buggy Hunk]
proto.getMeta());

[Patch]
proto.getMetaMap());