Move `if (bean instanceof MessageChannel)` outside of the for loop.