Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0058169 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [POS2] Core | major | have not tried | 2025-03-06 15:18 | 2025-03-07 14:02 | |||
Reporter | shuehner | View Status | public | |||||
Assigned To | shuehner | |||||||
Priority | normal | Resolution | fixed | Fixed in Version | 25Q2 | |||
Status | closed | Fix in branch | Fixed in SCM revision | |||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Review Assigned To | ||||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0058169: core2 : ModuleInfoGenerator has unstable output ordering (for lists) and is missing list values | |||||||
Description | The ModuleInfoGenerator (among other things) generated a file with the required ad_reflist entries (per language) for all ‘relevant’ modules. https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2/-/blob/master/src/org/openbravo/core2/build/ModuleInfoGenerator.java?ref_type=heads#L278 [^] To do that above functions merges the output of 3 calls to trlElementGenerator.apply. If that input is coming from LabelsComponent.getLists then its structure is { “ad_reference_id” : [ {“id”: “ad_ref_list.value”, “name”: as_ref_list.name”}, { nextEntry } ] The current code has 2 problems a.) The ordering of ad_ref_list entries is undefined/random in practice As the code https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.mobile.core/-/blob/master/src/org/openbravo/mobile/core/login/LabelsComponent.java?ref_type=heads#L109 [^] is ordering by ad_ref_list.ad_reference_id, ad_ref_list.seqno However the seqno field is not mandatory and sometimes null => That leads to ordering being undefined The order should be stable to avoid any confusion (for user, debugging, reproducible builds) b.) Some ad_ref_list values get lost and are missing in the generated output The mergeJsons function here https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2/-/blob/master/src/org/openbravo/core2/build/ModuleInfoGenerator.java?ref_type=heads#L298 [^] Just overwrites previous entries from its o1 input with values from o2 input. In case those are JSONArray’s that means that entries come from different calls here that the final entries are not the ‘merged’ entries of both arrays but only then ones from the ‘last’ merge. Depending on ordering of list values appearing in the 3 calls to getTrlElements that least to ‘lost’ ad_ref_list entries in the output. | |||||||
Steps To Reproduce | That effect can be seen when comparing generated POS2-lists files for unmodified pos2-modules.json and output after the fix from this bug report. comparing generated POS2-lists output pre- and post-merge of https://openbravo.atlassian.net/browse/RM-18205 [^] That 18205 merged org.openbravo.retail.config into core (intending to not change content + behavior) However regression testing of generated POS2-lists file showed that several ad_ref_list entries for unrelated org.openbravo.retail.posterminal get lost (indirectly caused by different processing order of modules). | |||||||
Proposed Solution | a.) add another orderBy field in LabelsComponent.getLists to ensure stable ordering b.) fix code in mergeJsons to properly merge the JSONArray values instead of overwriting the whole array. Note that fix for b.) should ensure to keep the array sorted to not 'undo' the improvement from a.) | |||||||
Tags | No tags attached. | |||||||
Attached Files | ||||||||
![]() |
|
![]() |
|
(0176531) hgbot (developer) 2025-03-06 15:24 |
Merge Request created: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/839 [^] |
(0176532) hgbot (developer) 2025-03-06 15:39 |
Merge Request created: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/1811 [^] |
(0176555) hgbot (developer) 2025-03-07 14:02 |
Repository: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.mobile.core [^] Changeset: 9e2e720a0ea08988630991e1b88be8844c686430 Author: Stefan Huehner <s.huehner@orisha.com> Date: 06-03-2025 15:25:39 URL: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.mobile.core/-/commit/9e2e720a0ea08988630991e1b88be8844c686430 [^] ISSUE-58169: Fix getLists output order to not be random Get HQL query in getLists orders the entry by: a.) ad_ref_list.ad_reference_id (needed for json building) b.) ad_ref_list.seqno (to user the defined functional order of list elements) However the seqno column is nullable so only a+b does not garantee any stable order. Adding 3rd column c.) ad_ref_list.value (aka searchKey) afterwards does not change the intended functional sorting but remove the random output by ensuring even on null seqno or duplicate seqno values the internal searchkey is used to have a predicable output ordering. Note that the stable order here only applies to the ad_ref_list values inside a specific reference. The order of references themselves is still unstable. That's caused by our use of JSONObject which by definition does not garantee any order of it's properties. --- M src/org/openbravo/mobile/core/login/LabelsComponent.java --- |
(0176556) hgbot (developer) 2025-03-07 14:02 |
Merge request merged: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/839 [^] |
(0176557) hgbot (developer) 2025-03-07 14:02 |
Merge request merged: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2/-/merge_requests/1811 [^] |
(0176558) hgbot (developer) 2025-03-07 14:02 |
Directly closing issue as related merge request is already approved. Repository: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2 [^] Changeset: f0c83ff8ad04369575addada040df27ba80e3329 Author: Stefan Huehner <s.huehner@orisha.com> Date: 07-03-2025 10:28:55 URL: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.core2/-/commit/f0c83ff8ad04369575addada040df27ba80e3329 [^] Fixes ISSUE-58169: Fix missing ad_ref_list entries in generated -lists When merging the outputs of 3 calls to LabelsComponent.getLists the code didn't take into account for the structure of the input jsons. For the ad_ref_lists the entries of the main JSONObject are JSONArray. Instead of overwriting the previous complete array it should merge the entries of both arrays. Without doing that the previous array entries get lost if the new array entries don't include all of them. While doing so the merge should: - Avoid adding duplicate entries to the array - Produce a stable output The mergesSortedJSONArrays function takes to sorted input JSONArray and produced the sorted merged output. The input must already: - have the correct structure with each element being JSONArray itself having (at least) and id attribute - Be sorted by value of this id attribute - Not have duplicate entries (with have id attribute) --- M src/org/openbravo/core2/build/ModuleInfoGenerator.java --- |
![]() |
|||
Date Modified | Username | Field | Change |
2025-03-06 15:18 | shuehner | New Issue | |
2025-03-06 15:18 | shuehner | Assigned To | => shuehner |
2025-03-06 15:18 | shuehner | Triggers an Emergency Pack | => No |
2025-03-06 15:24 | hgbot | Note Added: 0176531 | |
2025-03-06 15:39 | hgbot | Note Added: 0176532 | |
2025-03-07 14:02 | hgbot | Note Added: 0176555 | |
2025-03-07 14:02 | hgbot | Note Added: 0176556 | |
2025-03-07 14:02 | hgbot | Note Added: 0176557 | |
2025-03-07 14:02 | hgbot | Resolution | open => fixed |
2025-03-07 14:02 | hgbot | Status | new => closed |
2025-03-07 14:02 | hgbot | Fixed in Version | => 25Q2 |
2025-03-07 14:02 | hgbot | Note Added: 0176558 |
Copyright © 2000 - 2009 MantisBT Group |