Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036762Openbravo ERPA. Platformpublic2017-09-01 12:102017-09-21 16:49
JONHM 
caristu 
highmajorsometimes
closedfixed 
5
 
3.0PR17Q4 
alostale
Core
No
0036762: Window personalization list can not be loaded properly due to an error during its sorting
Window personalization list can not be loaded properly due to an error during its sorting.

The list of personalizations for a tab is sorted[1] before returning it to the client.

Since Java 7 Collections.sort uses TimSort. Using a non-transitive comparator for sorting in Java >= 7 will throw the following exception: java.lang.IllegalArgumentException: Comparison method violates its general contract!

And the PersonalizationComparator is not transitive when checking the priority by client.

[1] https://code.openbravo.com/erp/devel/pi/file/4fa54a2fb83d/modules/org.openbravo.client.application/src/org/openbravo/client/application/personalization/PersonalizationHandler.java#l270 [^]
[2] https://code.openbravo.com/erp/devel/pi/file/4fa54a2fb83d/modules/org.openbravo.client.application/src/org/openbravo/client/application/personalization/PersonalizationHandler.java#l601 [^]
Option A:

** Ask the environment to Support department **

1) Open 'Window Personalization' window and set active every views for user 'Diego' and window 'Product' (there will be 21)
2) Open 'Product' window and click the 'Save View' button on the toolbar. The following error is fired in the log (see attached the full log):

Caused by: org.openbravo.base.exception.OBException: Exception when getting personalization settings for window ADWindow(140) (name: Product)
    at org.openbravo.client.application.personalization.PersonalizationHandler.getPersonalizationsForWindow(PersonalizationHandler.java:254)
    at org.openbravo.client.application.personalization.PersonalizationHandler.getPersonalizationForWindow(PersonalizationHandler.java:98)
    ... 57 more
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
    at java.util.TimSort.mergeHi(TimSort.java:895)
    at java.util.TimSort.mergeAt(TimSort.java:512)
    at java.util.TimSort.mergeCollapse(TimSort.java:437)
    at java.util.TimSort.sort(TimSort.java:241)
    at java.util.Arrays.sort(Arrays.java:1512)
    at java.util.ArrayList.sort(ArrayList.java:1454)
    at java.util.Collections.sort(Collections.java:175)
    at org.openbravo.client.application.personalization.PersonalizationHandler.sortPersonalizations(PersonalizationHandler.java:270)
    at org.openbravo.client.application.personalization.PersonalizationHandler.getPersonalizationsForWindow(PersonalizationHandler.java:251)
    ... 58 more


Option B:

1) Attached is patch with a test case that checks if the PersonalizationHandler is transitive. Apply it.
2) Run test.
Change the PersonalizationHandler in order to fulfill the Comparable[1] contract.

[1] http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Comparable.html [^]
No tags attached.
? personalizationView.mp4 (4,128,920) 2017-09-01 12:10
https://issues.openbravo.com/file_download.php?file_id=11029&type=bug
txt stackTrace.txt (6,777) 2017-09-05 18:29
https://issues.openbravo.com/file_download.php?file_id=11041&type=bug
diff testIssue36762.diff (4,118) 2017-09-06 09:14
https://issues.openbravo.com/file_download.php?file_id=11043&type=bug
Issue History
2017-09-01 12:10JONHMNew Issue
2017-09-01 12:10JONHMAssigned To => platform
2017-09-01 12:10JONHMModules => Core
2017-09-01 12:10JONHMResolution time => 1506031200
2017-09-01 12:10JONHMTriggers an Emergency Pack => No
2017-09-01 12:10JONHMFile Added: personalizationView.mp4
2017-09-05 18:29caristuSummary'Save button' on the toolbar is not shown when containing many views having its personalization too complex => Window personalization list can not be loaded properly due to an error during its sorting
2017-09-05 18:29caristuDescription Updatedbug_revision_view_page.php?rev_id=15821#r15821
2017-09-05 18:29caristuSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15823#r15823
2017-09-05 18:29caristuProposed Solution updated
2017-09-05 18:29caristuFile Added: stackTrace.txt
2017-09-05 18:30caristuFile Added: testIssue36762.diff
2017-09-05 18:31caristuSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15824#r15824
2017-09-05 18:38hgbotCheckin
2017-09-05 18:38hgbotNote Added: 0098854
2017-09-05 18:39caristuAssigned Toplatform => caristu
2017-09-05 18:56caristuStatusnew => acknowledged
2017-09-05 18:57caristuStatusacknowledged => scheduled
2017-09-06 08:59hgbotCheckin
2017-09-06 08:59hgbotNote Added: 0098857
2017-09-06 08:59hgbotStatusscheduled => resolved
2017-09-06 08:59hgbotResolutionopen => fixed
2017-09-06 08:59hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1db6083af55beef5807175ef1ec7147a1410168e [^]
2017-09-06 09:06caristuReview Assigned To => alostale
2017-09-06 09:14caristuFile Deleted: testIssue36762.diff
2017-09-06 09:14caristuFile Added: testIssue36762.diff
2017-09-08 12:18alostaleNote Added: 0098905
2017-09-08 12:18alostaleStatusresolved => closed
2017-09-08 12:18alostaleFixed in Version => 3.0PR17Q4
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099361
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099363

Notes
(0098854)
hgbot   
2017-09-05 18:38   
Repository: erp/devel/pi
Changeset: 269bf16d019e6366d087cec1995af2c8d870d41f
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Tue Sep 05 18:37:33 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/269bf16d019e6366d087cec1995af2c8d870d41f [^]

related to issue 36762: minor code clean-up
  - Use org.slf4j.Logger to log
  - Added an error log message
  - Remove unneeded comments
  - Use diamond operator
  - Updated copyright year

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/personalization/PersonalizationHandler.java
---
(0098857)
hgbot   
2017-09-06 08:59   
Repository: erp/devel/pi
Changeset: 1db6083af55beef5807175ef1ec7147a1410168e
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 06 08:58:05 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1db6083af55beef5807175ef1ec7147a1410168e [^]

fixes bug 36762: The comparator to sort window personalizations wasn't complete

  Since Java 7 Collections.sort uses TimSort. Using a non-transitive comparator for sorting in Java >= 7 can throw the following exception: "java.lang.IllegalArgumentException: Comparison method violates its general contract!" depending on the comparisons performed by the comparator.

  The PersonalizationComparator violated the Comparable contract when checking the priority by client between two window personalizations to calculate their position. Now this problem has been solved.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/personalization/PersonalizationHandler.java
---
(0098905)
alostale   
2017-09-08 12:18   
reviewed + tested
(0099361)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099363)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test