-
Notifications
You must be signed in to change notification settings - Fork 193
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
replace anonymous runnable class with lambda #1459
replace anonymous runnable class with lambda #1459
Conversation
Test Results 899 files - 1 899 suites - 1 36m 3s ⏱️ - 30m 46s For more details on these failures, see this check. Results for commit 605c868. ± Comparison against base commit f746493. ♻️ This comment has been updated with latest results. |
5002bb3
to
8b937a5
Compare
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 don't think this change is safe. Usually, a class that defines a field shouldn't be turned into a lambda as the field lifecycle (which value they get and where) matters.
@@ -872,18 +872,14 @@ public void processEvent(VerifyEvent e) { | |||
private void filterProposals() { | |||
++ fInvocationCounter; | |||
Control control= fViewer.getTextWidget(); | |||
control.getDisplay().asyncExec(new Runnable() { | |||
control.getDisplay().asyncExec(() -> { |
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 not equivalent and will most likely cause bugs:
@@ -872,18 +872,14 @@ public void processEvent(VerifyEvent e) { | |||
private void filterProposals() { | |||
++ fInvocationCounter; | |||
Control control= fViewer.getTextWidget(); | |||
control.getDisplay().asyncExec(new Runnable() { | |||
control.getDisplay().asyncExec(() -> { | |||
long fCounter= fInvocationCounter; |
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.
Before, fCounter is initialized just once, when filterProposals
is invoked and the Runnable
is created, ie before actually running the Runnable. While with the change, the value is set at execution of the Runnable, leading to...
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.
will moving fCounter
assignment outside of the lambda solve the problem?
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.
Yes, I think it would.
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.
@mickaelistria I have made that change accordingly and removed the problematic lambda. please have a look.
@Override | ||
public void run() { | ||
|
||
if (fCounter != fInvocationCounter) |
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 condition not being always true (before) but being always true (after)
|
||
fContextInfoPopup.getDisplay().asyncExec(new Runnable() { | ||
|
||
private ContextFrame fFrame= fContextFrameStack.peek(); |
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 similar pattern here: the frame is set once at instantiation for some reason, not on the execution. This looks like an actual intent to capture the "initial value before execution".
8b937a5
to
605c868
Compare
Thank you! |
* replace anonymous runnable class with lambda
No description provided.