Fixed a potential java.lang.StackOverflowError issue