When selecting a pokerHand of Trio with kicker and clicking the 'play' button, the program crashed with ConcurrentModificationException. It seems that this error is triggered by the getCardList() method in the TrioBase class. Expect output: The pokerHand is accepted by table, and game continues. Actual output: The game was blocked and error message appeared.
The problem is caused by: 1. When constructing a poker hand with kickers, it uses .subList() to split the original card list. Therefore, the components are actually different parts of the same ArrayList<Card>. 2. When invoking getCardList(), it concatenates the kicker to its components, which is equivalent to insert the kickers to the original array list and hence goes wrong. The problem has been solved, it returns a new array list with the same elements.