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

New RequestScopeHelper class to track request scopes across threads #2856

Merged
merged 7 commits into from Mar 16, 2021

Conversation

spericas
Copy link
Member

New class in FT that isolates code related to saving and restoring request scopes. The new class RequestScopeHelper provides support for CDI, HK2 and multiple JAX-RS applications; it includes additional code to track injection managers across threads. New test that verifies issue reported in #2632. For more information, see #2632 (comment)

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
… of thread local variable in Jersey to make sure correct InjectionManager is used in non-request threads.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
…ultiple applications.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
@spericas spericas added fault-tolerance jax-rs JAX-RS and Jersey related issues labels Mar 11, 2021
@spericas spericas self-assigned this Mar 11, 2021
Copy link
Member

@tjquinno tjquinno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with one question.

Comment on lines +301 to +302
requestScopeHelper = new RequestScopeHelper();
requestScopeHelper.saveScope();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we ever legitimately instantiate a helper without also saving the scope right away?

If not, maybe fold the save work into the constructor? Or make the constructor private and use a static factory method that instantiates the helper and then invokes its saveScope method?

That would not work if there are ever cases where a single helper instance is created and then reused through several save and clear cycles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a use case for saving/clearing/saving yet, so it is a bit more generic than necessary. Having said that, I think it easier to read with an explicit call to saveScope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern was that correct usage requires me to remember to both instantiate the helper and invoke saveScope explicitly. This is internal so I'm not overly worried.

@romain-grecourt
Copy link
Contributor

Can you rename this PR to something meaningful and use Fixes #2632. Otherwise it shows up in the git log and does mean much after a while.

@spericas spericas changed the title Fix for issue 2632 New RequestScopeHelper class to track request scopes across threads Mar 15, 2021
@spericas spericas merged commit ac64239 into helidon-io:master Mar 16, 2021
paulparkinson pushed a commit that referenced this pull request Mar 29, 2021
…2856)

* Run concurrent requests for each test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New helper class to manage request scope logic across threads. Update of thread local variable in Jersey to make sure correct InjectionManager is used in non-request threads.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Updated test to show the problem described in #2632 using multiple applications.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Fixed copyright.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
barchetta pushed a commit that referenced this pull request Mar 30, 2021
…2856)

* Run concurrent requests for each test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New helper class to manage request scope logic across threads. Update of thread local variable in Jersey to make sure correct InjectionManager is used in non-request threads.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Updated test to show the problem described in #2632 using multiple applications.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Fixed copyright.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
aseovic pushed a commit to aseovic/helidon that referenced this pull request Apr 26, 2021
…elidon-io#2856)

* Run concurrent requests for each test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New test.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* New helper class to manage request scope logic across threads. Update of thread local variable in Jersey to make sure correct InjectionManager is used in non-request threads.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Updated test to show the problem described in helidon-io#2632 using multiple applications.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Fixed copyright.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fault-tolerance jax-rs JAX-RS and Jersey related issues
Projects
Backlog
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

3 participants