-
Notifications
You must be signed in to change notification settings - Fork 592
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
Block contextual operations from lazily enlisting CDI beans #8348
Block contextual operations from lazily enlisting CDI beans #8348
Conversation
Code analysis and actionsDO NOT DELETE THIS COMMENT.
|
# Contributors: | ||
# IBM Corporation - initial API and implementation | ||
############################################################################### | ||
#CMVCPATHNAME com.ibm.ws.concurrent/resources/com/ibm/ws/concurrent/resources/CWWKCMessages.nlsprops |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this commented line matters, but com.ibm.ws.concurrent should be switched to com.ibm.ws.cdi.mp.context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't matter, it just can't be blank
|
||
# do not translate: CDI, CompletionStage | ||
CWWKC1158.cannot.lazy.enlist.beans=CWWKC1158E: CDI beans used in contextual operations, such as a CompletionStage, must be accessed using a CDI bean operation, such as a public \ | ||
method, before context for the operation is captured. The CDI beans that were not accessed before context was captured are: {0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to state this directly in terms of what the user must do to fix the problem? For example,
"You must access CDI beans {0} prior to capturing context for the contextual action or task in order for the CDI beans to behave correctly when accessed from the action or task."
The way it is currently written makes it less clear that it is the user's/application's responsibility to take action to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to have {0}
at the end of the message because it can get very long, because ContextualInstance toString() includes lots of information such as what qualifiers are on the bean. Also, a large list of beans could be provided.
I could change the last sentence from:
The CDI beans that were not accessed before context was captured are: {0}
to be:
The following CDI beans must be accessed before capturing context: {0}
to make it more clear what action the user needs to take
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine to put the list at the end. However, my comment about writing this more directly and including the word "you" still applies. Maybe we could combine the two?
"You must access CDI beans prior to capturing context for the contextual action or task in order for the CDI beans to behave correctly when accessed from the action or task. The following CDI beans must be accessed before capturing context: {0}."
It would be good to get the ID reviewer involved here to tell us what we can and cannot say in a message, and they may have some ideas for improving clarity as well.
@@ -68,6 +68,12 @@ public void run() { | |||
try { | |||
if (contextApplied != null) | |||
threadContextDescriptor.taskStopping(contextApplied); | |||
} catch (RuntimeException x) { | |||
// prioritize surfacing an actual task failure over a failure clearing context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we switch the prioritization in ContextualRunnable, we should do so in every other contextual action type as well (Function, BiFunction, Consumer, Supplier, ...). That said, I'm not convinced that we ought to switch the ordering. A failure to clear context is very severe, and typically would be more important than a task's own exception (which might even sometimes be expected). I would argue that also applies in the case for which these changes are being added.
} | ||
} | ||
assertTrue("CompletableFuture should have been marked done", cf.isDone()); | ||
assertTrue("CompletableFuture should have been marked as completex exceptionally", cf.isCompletedExceptionally()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo: completex -> completed
L2 message review complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested some minor changes.
# | ||
# NLS_MESSAGEFORMAT_VAR | ||
# | ||
# Strings in this file which contain replacement variables are processed by the MessageFormat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'Strings in this file which contain replacement variables are processed by the MessageFormat # class (single quote must be coded as 2 consecutive single quotes '').'
to
'Strings in this file, which contain replacement variables, are processed by the MessageFormat #class (single quotation mark must be coded as two consecutive single quotation marks '').'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a boilerplate header comment (not an NLS message) so I'm going to leave as-is. Any line that starts with #
in a .nlsprops file is a comment and a user will never see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
# NLS_MESSAGEFORMAT_VAR | ||
# | ||
# Strings in this file which contain replacement variables are processed by the MessageFormat | ||
# class (single quote must be coded as 2 consecutive single quotes ''). Strings in this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'Strings in this file, which do NOT contain replacement variables are NOT processed by the MessageFormat class'
to
'Strings in this file, which do NOT contain replacement variables are NOT processed by the MessageFormat class (single quotation mark must be coded as one single quote '). '
(single quote must be coded as one single quote '). '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a boilerplate header comment (not an NLS message) so I'm going to leave as-is. Any line that starts with #
in a .nlsprops file is a comment and a user will never see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
# (single quote must be coded as one single quote '). | ||
|
||
# This message bundle does not have its own message range, and instead reserves specific error messages from the | ||
# com.ibm.ws.concurrent.mp.1.0 message bundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
' This message bundle does not have its own message range, and instead reserves specific error messages from the com.ibm.ws.concurrent.mp.1.0 message bundle'.
to
'This message bundle does not have its own message range. Instead, it reserves specific error messages from the com.ibm.ws.concurrent.mp.1.0 message bundle '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a boilerplate header comment (not an NLS message) so I'm going to leave as-is. Any line that starts with #
in a .nlsprops file is a comment and a user will never see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
|
||
# do not translate: CDI, CompletionStage | ||
CWWKC1158.cannot.lazy.enlist.beans=CWWKC1158E: CDI beans used in contextual operations, such as a CompletionStage, must be accessed using a CDI bean operation, such as a public \ | ||
method, before context for the operation is captured. The CDI beans that were not accessed before context was captured are: {0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'CDI beans used in contextual operations, such as a CompletionStage, must be accessed using a CDI bean operation, such as a public method, before context for the operation is captured. The CDI beans that were not accessed before context was captured are: {0} '
to
' CDI beans used in contextual operations, such as a CompletionStage, must be accessed by using a CDI bean operation, such as a public method, before context for the operation is captured. The CDI beans that were not accessed before the context was captured are: {0} '
#build |
Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_KWl_YK7uEemoaqXqE6v4jQ Target locations of links might be accessible only to IBM employees. |
Your Open Liberty build results are ready for viewing.
|
#build |
Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_8GicEK-bEemoaqXqE6v4jQ Target locations of links might be accessible only to IBM employees. |
Your Open Liberty build results are ready for viewing.
|
1720ee8
to
1404ad8
Compare
#build |
Your personal build request is at https://wasrtc.hursley.ibm.com:9443/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_LdmKELFnEemoaqXqE6v4jQ Target locations of links might be accessible only to IBM employees. |
Your Open Liberty build results are ready for viewing.
|
The build aguibert-8348-20190728-1947 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few additional proposed changes.
|
||
# do not translate: CDI, CompletionStage | ||
CWWKC1158.cannot.lazy.enlist.beans=CWWKC1158E:You must access CDI beans prior to capturing context for the contextual action or task in order for the CDI \ | ||
beans to behave correctly when accessed from the action or task. The following CDI beans must be accessed before capturing context: {0}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'You must access CDI beans prior to capturing context for the contextual action or task in order for the CDI \ beans to behave correctly when accessed from the action or task. The following CDI beans must be accessed before capturing context: {0}.'
to
'The following CDI beans were not accessed before the context was captured: {0}. You must access the CDI beans before context is captured for the contextual action or task so that the CDI beans behave correctly. '
CWWKC1158.cannot.lazy.enlist.beans=CWWKC1158E:You must access CDI beans prior to capturing context for the contextual action or task in order for the CDI \ | ||
beans to behave correctly when accessed from the action or task. The following CDI beans must be accessed before capturing context: {0}. | ||
CWWKC1158.cannot.lazy.enlist.beans.explanation=When CDI context is captured, only CDI beans that have been accessed at that point in time have been created by \ | ||
the CDI runtime. As a result, CDI beans that are first accessed in contextual operations cannot propagate their state correctly to subsequent contextual operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'When CDI context is captured, only CDI beans that have been accessed at that point in time have been created by \ the CDI runtime. As a result, CDI beans that are first accessed in contextual operations cannot propagate their state correctly to subsequent contextual operations.'
to
'When the CDI context is captured, only CDI beans that are accessed at that point are created by the CDI runtime. As a result, CDI beans that are first accessed in contextual operations cannot propagate their state correctly to subsequent contextual operations.'
CWWKC1158.cannot.lazy.enlist.beans.explanation=When CDI context is captured, only CDI beans that have been accessed at that point in time have been created by \ | ||
the CDI runtime. As a result, CDI beans that are first accessed in contextual operations cannot propagate their state correctly to subsequent contextual operations. | ||
CWWKC1158.cannot.lazy.enlist.beans.useraction=The application must be changed to invoke some CDI bean operation, such as a public method, before context for \ | ||
the operation is captured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change
'The application must be changed to invoke some CDI bean operation, such as a public method, before context for \ the operation is captured.'
to
'The application must be changed to start a CDI bean operation, such as a public method, before a context for the operation is captured.'
# | ||
# NLS_MESSAGEFORMAT_VAR | ||
# | ||
# Strings in this file which contain replacement variables are processed by the MessageFormat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
# NLS_MESSAGEFORMAT_VAR | ||
# | ||
# Strings in this file which contain replacement variables are processed by the MessageFormat | ||
# class (single quote must be coded as 2 consecutive single quotes ''). Strings in this file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
# (single quote must be coded as one single quote '). | ||
|
||
# This message bundle does not have its own message range, and instead reserves specific error messages from the | ||
# com.ibm.ws.concurrent.mp.1.0 message bundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
Intermediate solution to the MP Context Propagation issue identified here:
eclipse/microprofile-context-propagation#167