Skip to content

Commit

Permalink
Adds filter to empty VM hook in RootVmHook.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-shevchenko committed Oct 17, 2018
1 parent a207aee commit 3ae595f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -46,6 +47,8 @@ public RootVmHook(Optional<VMHook[]> hooks) {

private void proxySafeToAll(Consumer<VMHook> action) {
for (VMHook hook : hooks) {
if (hook.isEmpty()) continue;

try {
action.accept(hook);
} catch (Throwable t) {
Expand All @@ -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();
}
}

0 comments on commit 3ae595f

Please sign in to comment.