Bug 306 - Duplicated CPU entries are generated when the CPU list is sorted
Summary: Duplicated CPU entries are generated when the CPU list is sorted
Status: RESOLVED FIXED
Alias: None
Product: Group17
Classification: Unclassified
Component: Component Controller (show other bugs)
Version: unspecified
Hardware: PC Windows
: Normal normal
Deadline: 2019-11-20
Assignee: kinluntam2-c
URL:
Depends on:
Blocks:
 
Reported: 2019-11-19 20:19 HKT by chiwmak2-c
Modified: 2019-11-19 23:14 HKT (History)
1 user (show)

See Also:


Attachments
Duplicated sorted CPU list (50.92 KB, image/png)
2019-11-19 20:19 HKT, chiwmak2-c
Details
Capture of CPU List after the bug is fixed (183.87 KB, image/jpeg)
2019-11-19 23:14 HKT, kinluntam2-c
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chiwmak2-c 2019-11-19 20:19:50 HKT
Created attachment 25 [details]
Duplicated sorted CPU list

When I click the column header to sort the CPU list, the sorted list is generated with one more duplicated CPU entry for each CPU product. The expected result should be no duplicated entry and the list is sorted according to the criteria.

Step to reproduction:
1. click the CPU List tab
2. click any one of the column header to call the "CPUController" function

The problem is only happened in CPU list and doesn't throw any exception. I found the potential problem is that the class "SpecList" needs to get the sorted CPU data for calculation, so the class "DIYTab" creates a new "CPUController" instance for "SpecList". Due to the ArrayList for holding CPU information is a static field, create a new "CPUController" instance will affect the ArrayList.

I suggest to change the function about get sorted data to be static function, so that the "SpecList" instance can get the sorted data for calculation without created a duplicated "CPUController".
Comment 1 kinluntam2-c 2019-11-19 22:49:49 HKT
The bug is now be fixed by changing the getSortedList function in the CPUController Class, into a static function. The DIYTab class will now create a new specList object, and call the findList function in the specList to get the CPU data. It prevents creating a new CPUController object before getting the data, and solves the problem of putting duplicate tuples into the cpuList.
Comment 2 kinluntam2-c 2019-11-19 23:14:36 HKT
Created attachment 27 [details]
Capture of CPU List after the bug is fixed