[BLOSSOM-282] Race condition in the DialogCreationContextHolder or Creator Created: 06/Oct/21  Updated: 20/Oct/21  Resolved: 08/Oct/21

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 3.4.5
Fix Version/s: 3.4.6

Type: Bug Priority: Critical
Reporter: Mikaël Geljić Assignee: Mikaël Geljić
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Date of First Response:

 Description   

via reopening comment on SUPPORT-13357:

i think the solution for this topic has some race condition. Maybe a Problem in the DialogCreationContextHolder oder Creator... so i sadly must reopen that issue.

We are using the following

@DialogFactory(TestDialog.DIALOG_ID)
public class TestDialog {

   public static final String DIALOG_ID = "myTestDialog";
   private static final Logger LOG = LoggerFactory.getLogger(TestDialog.class);

   @TabFactory("buttonLinkDialog.button.tab.label")
   public void buttonLinkTab(Node node, UiConfig uiConfig, TabBuilder tabBuilder) {
      tabBuilder.fields(
            uiConfig.fields.text("keepitsimple").label("Simple Field"),
            uiConfig.fields.text("keepitlocalized").label("Locale Field").i18n().required()
      );

   }


   @PostCreate(value = PostCreate.Phase.AFTER_SUB_CLASSES)
   public void postCreateReferenceTab(Node node, DialogBuilder dialogBuilder) {
      LOG.info("Calling postCreateReferenceTab with node {}", NodeUtil.getNodePathIfPossible(node));
   }

} 

just to print the node path for the node that is passed to the annotated method.
When i open a page and edit a component using this dialog for the first time everything is fine. Reopening it works as well, but as soon as i have several components within the same page things getting weird.
Most of the times the first edit of each component is correct. The node passed to the method is the one that is being edited.
But afterwards the nodes are getting mixed, the passed node to the post create method does no longer fit to the edited node.
See Screen - i clicked edit on each component and reported the log output for it. The nodes are named as they contain content, see another screen.



 Comments   
Comment by Mikaël Geljić [ 06/Oct/21 ]

DialogCreationContextHolder's threadlocal was never cleared after dialog-creators have run, so subsequent requests handled by a recycled thread would get obsolete node references :facepalm:.

Former BlossomFormDialogPresenter has been doing that for 5 UI forever. For 6 UIDialogCreatorDefinitionDecorator originally didn't set it, until we supported context injection again in BLOSSOM-276 / 3.4.5.

Generated at Sun Feb 11 23:31:56 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.