demo code for reproduce StackOverflow and NoSuchElementException