Bug 337 - Program will crash when a pokerHand of TrioX or TrioXX is played
Summary: Program will crash when a pokerHand of TrioX or TrioXX is played
Status: RESOLVED FIXED
Alias: None
Product: Group 8 (2019)
Classification: Unclassified
Component: Player (show other bugs)
Version: Version1.0
Hardware: PC Mac OS
: --- blocker
Assignee: ZLQ
URL:
Depends on:
Blocks:
 
Reported: 2019-12-04 21:25 HKT by LXL
Modified: 2019-12-05 13:00 HKT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LXL 2019-12-04 21:25:20 HKT
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.
Comment 1 ZLQ 2019-12-05 13:00:28 HKT
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.