diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java b/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java index 1022b48c0c..ad38093d65 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java @@ -25,6 +25,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.Optional; import java.util.function.Consumer; @@ -46,6 +47,8 @@ public RootVmHook(Optional hooks) { private void proxySafeToAll(Consumer action) { for (VMHook hook : hooks) { + if (hook.isEmpty()) continue; + try { action.accept(hook); } catch (Throwable t) { @@ -71,6 +74,10 @@ public void stopPlay(Program program) { @Override public boolean isEmpty() { - return hooks.length == 0; + return hooks.length == 0 || emptyHooksCount() == hooks.length; + } + + private long emptyHooksCount() { + return Arrays.stream(hooks).filter(VMHook::isEmpty).count(); } }