Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Context Propagation Error in Asynchronous Task Execution #27540

Closed
jgambarios opened this issue Feb 7, 2024 · 0 comments · Fixed by #27527
Closed

CLI: Context Propagation Error in Asynchronous Task Execution #27540

jgambarios opened this issue Feb 7, 2024 · 0 comments · Fixed by #27527

Comments

@jgambarios
Copy link
Contributor

jgambarios commented Feb 7, 2024

Problem Statement

We've identified an issue in our application where the context is not properly propagated in asynchronous task executions. This problem affects our ability to maintain consistent state and context (e.g., security context, transactional context) across asynchronous operations, leading to unpredictable behavior and errors during runtime.

Problem Details

The issue arises when executing asynchronous tasks that rely on context inherited from the parent thread. Due to the nature of our asynchronous operations, the context is not automatically propagated, resulting in tasks that execute in a contextually "blank" state.

Proposed Solution

After investigating potential solutions, we've determined that utilizing the ManagedExecutor service from MicroProfile Context Propagation is the most effective way to address this issue. ManagedExecutor ensures that the context is captured from the thread that submits the task and is then propagated to the thread that executes the task.

Implementation Details

The fix involves refactoring our existing asynchronous task execution model to leverage ManagedExecutor. This change will ensure that context is properly captured and propagated across asynchronous boundaries, maintaining consistent behavior across our application.

Specific changes include:

  • Replacing direct usage of CompletableFuture and other native Java concurrency mechanisms with ManagedExecutor.
  • Ensuring all asynchronous tasks are submitted through ManagedExecutor for execution.
  • Adjusting unit and integration tests to account for the new asynchronous execution model.

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

@jgambarios jgambarios self-assigned this Feb 7, 2024
jgambarios added a commit that referenced this issue Feb 8, 2024
…ava concurrency mechanisms with ManagedExecutor
jgambarios added a commit that referenced this issue Feb 10, 2024
…ava concurrency mechanisms with ManagedExecutor
jgambarios added a commit that referenced this issue Feb 12, 2024
…` class to return an empty map instead of null allowing proper comparison between local descriptors and server content types.
jgambarios added a commit that referenced this issue Feb 13, 2024
Moved common functionality of FilesTree and FilesLs into new AbstractFilesListingCommand for code reuse and simplified their implementations appropriately. The changes aim to improve maintainability and code clarity by avoiding repetition.
jgambarios added a commit that referenced this issue Feb 13, 2024
Glob pattern options for including or excluding files and folders have been refactored into a mixin class, FilesGlobMixin. This change enhances code reusability and modularity, making the pattern options more accessible across different classes without the need for replication.
jgambarios added a commit that referenced this issue Feb 13, 2024
@nollymar nollymar removed the Triage label Feb 13, 2024
jgambarios added a commit that referenced this issue Feb 14, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 14, 2024
* #26633 Update dotCMS remote folder traversal process and tests

Modified the dotCMS remote location traversal process to incorporate parallel execution of tasks using a ManagedExecutor. Removed unnecessary imports, adjusted the exception handling methods, enhanced test stability by sorting files and folders before assertion, and other necessary logic modifications.

* #27540 Replacing direct usage of CompletableFuture and other native Java concurrency mechanisms with ManagedExecutor

* #27540 Removing all @disabled annotations in tests

* #27540 Replacing direct usage of CompletableFuture and other native Java concurrency mechanisms with ManagedExecutor

* #27540 The code change modifies the `metadata` method in `ContentType` class to return an empty map instead of null allowing proper comparison between local descriptors and server content types.

* #27540 Refactor file listing commands for modularity

Moved common functionality of FilesTree and FilesLs into new AbstractFilesListingCommand for code reuse and simplified their implementations appropriately. The changes aim to improve maintainability and code clarity by avoiding repetition.

* #27540 Refactor glob pattern options into a mixin

Glob pattern options for including or excluding files and folders have been refactored into a mixin class, FilesGlobMixin. This change enhances code reusability and modularity, making the pattern options more accessible across different classes without the need for replication.

* #27540 Refactor FilePullMixin to FilesPullMixin

* #27540 Adding NOSCAN to avoid attributes of some builders to be marked as duplicated.

* #27540 Applying sonarlint feedback to avoid duplicated code

* #27540 Applying code review feedback: FileHashCalculatorService service exposed as an interface.
@nollymar nollymar added the Release : 24.03.1 Announcements label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants