@Override
    protected Object newInstance() {
        if (arguments == null) {
            throw new IllegalStateException("graph.complete must be called before retrieving instances.");
        }

        List<Object> actualArguments = new ArrayList<>();
        for (Object ob : arguments) {
            if (ob instanceof Node) {
                actualArguments.add(((Node) ob).component());
            } else if (ob instanceof ConfigKey<?>) {
                actualArguments.add(getConfigInstance((ConfigKey<?>)ob));
            } else {
                actualArguments.add(ob);
            }
        }

        Object instance;
        try {
            log.log(FINE, () -> "Constructing " + idAndType());
            Instant start = Instant.now();
            instance = constructor.newInstance(actualArguments.toArray());
            Duration duration = Duration.between(start, Instant.now());
            log.log(duration.compareTo(Duration.ofMinutes(1)) > 0 ? INFO : FINE,
                    () -> "Finished constructing " + idAndType() + " in " + duration);
        } catch (InvocationTargetException | InstantiationException | IllegalAccessException | IllegalArgumentException | ClassCastException e) {
            StackTraceElement dependencyInjectorMarker = new StackTraceElement("============= Dependency Injection =============", "newInstance", null, -1);
            throw removeStackTrace(new ComponentConstructorException("Error constructing " + idAndType() + ": " + e.getMessage(), cutStackTraceAtConstructor(e.getCause(), dependencyInjectorMarker)));
        }

        return initId(instance);
    }
@author Tony Vaagenes
@author gjoranv
@author ollivir
container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java