Skip to content

Make sure Launch Bar Manager sends event at a correct time - #1486

Draft
DangMinhTam382 wants to merge 6 commits into
eclipse-cdt:mainfrom
DangMinhTam382:LaunchBarNewEvent
Draft

DangMinhTam382 wants to merge 6 commits into
eclipse-cdt:mainfrom
DangMinhTam382:LaunchBarNewEvent

Conversation

@DangMinhTam382

Copy link
Copy Markdown
Contributor

When active descriptor changed, and fireActiveLaunchDescriptorChanged() is called, current active mode and target are out of sync. This puts listeners at risk of handling event with false data for the changed descriptor.

Changed it so that only fire event when related fields are finished updating

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Test Results

0 files   -   216  0 suites   - 216   0s ⏱️ - 25m 8s
0 tests  - 5 937  0 ✅  - 5 806  0 💤  - 131  0 ❌ ±0 
0 runs   - 5 936  0 ✅  - 5 805  0 💤  - 131  0 ❌ ±0 

Results for commit 2965707. ± Comparison against base commit 8a79681.

♻️ This comment has been updated with latest results.

@DangMinhTam382

Copy link
Copy Markdown
Contributor Author

Hi Mr. @betamaxbandit ,
CC: Mr. @Kummallinen ,

Before making this PR official, could you take a quick look and let me know what you think?

Thanks!

@DangMinhTam382
DangMinhTam382 force-pushed the LaunchBarNewEvent branch 2 times, most recently from 17292ff to aa7a299 Compare September 16, 2026 12:02

@DangMinhTam382 DangMinhTam382 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,
CC: Mr. @Kummallinen ,

I added some UTs and replied to your comments on this PR.
Please have a look at it again.

Also, build is failed atm with errors:

[ERROR] org.eclipse.linuxtools.docker.editor.ls 1.0.1.202609160755 requires Execution Environment that matches (&(osgi.ee=JavaSE)(version=25)) but the current resolution context uses [a.jre.javase 21.0.0]
[ERROR] Cannot resolve target definition:
[ERROR] Software being installed: org.eclipse.linuxtools.docker.feature.feature.group 5.25.0.202609160755
[ERROR] Missing requirement for filter properties ~= $0: org.eclipse.linuxtools.docker.editor.ls 1.0.1.202609160755 requires 'osgi.ee; (&(osgi.ee=JavaSE)(version=25)), filter=(!(org.eclipse.equinox.p2.disable.require.capability.osgi.ee=true))' but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.linuxtools.docker.editor.ls.feature.feature.group 5.25.0.202609160755 depends on: org.eclipse.equinox.p2.iu; org.eclipse.linuxtools.docker.editor.ls [1.0.1.202609160755,1.0.1.202609160755]
[ERROR] Cannot satisfy dependency: org.eclipse.linuxtools.docker.feature.feature.group 5.25.0.202609160755 depends on: org.eclipse.equinox.p2.iu; org.eclipse.linuxtools.docker.editor.ls.feature.feature.group [5.25.0.202609160755,5.25.0.202609160755]
[ERROR]

Maybe something not working on the server?
Will look into this.

* @throws InterruptedException
*/
@Test
public void launchBarStateTest_LaunchDescriptorChanged() throws CoreException, InterruptedException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @DangMinhTam382 ,

thanks for adding the regression test. I think this is good since you added launchBarStateTest_LaunchDescriptorChanged; it's a good test.

But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.

Even though I think I guided you against doing this I think it might be better to test all three states in the single test.

Set the exact state the descriptor test currently prepares:
before switch:
descriptor2 / target2 / run

switch to:
descriptor1 / target1 / preferredMode1

Then install one listener implementing all three callbacks:
activeLaunchDescriptorChanged(...)
activeLaunchTargetChanged(...)
activeLaunchModeChanged(...)

For every callback generated by
setActiveLaunchDescriptor(desc_no1)

capture:
getActiveLaunchDescriptor()
getActiveLaunchTarget()
getActiveLaunchMode()

and afterwards verify that every captured state was:
descriptor1 / target1 / preferredMode1

That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,

But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.

It does not fail without fix.
I added them as an extra cover for the ILaunchBarListener.class
3 UT I added is testing for 3 checkpoint:

  • Launch descriptor changed
  • Launch target changed
  • Launch mode changed

And after the change happens, launch bar fields is capture each time an event is catched in ILaunchBarListener.class.

That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."

That's a good idea.
I updated the UT.
Now, the test ILaunchBarListener captures all events and records the launch bar state at that time.
All those records are verified afterward.

@betamaxbandit betamaxbandit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking much better now the regression has been added. I have added a few comments about the extra tests.
See what you think Tam.

@DangMinhTam382 DangMinhTam382 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,
Thanks for the comments.
The suggestion you made on the UT is really on point.
I updated them and this should be ready now

* @throws InterruptedException
*/
@Test
public void launchBarStateTest_LaunchDescriptorChanged() throws CoreException, InterruptedException {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,

But not sure about launchBarStateTest_LaunchTargetChanged and launchBarStateTest_LaunchModeChanged. Do they fail without the current fix in? I might have misread this so check what I'm saying please.

It does not fail without fix.
I added them as an extra cover for the ILaunchBarListener.class
3 UT I added is testing for 3 checkpoint:

  • Launch descriptor changed
  • Launch target changed
  • Launch mode changed

And after the change happens, launch bar fields is capture each time an event is catched in ILaunchBarListener.class.

That would directly test the stated design:
"Whenever an event is fired, launch bar manager is expected to have up-to-date fields."

That's a good idea.
I updated the UT.
Now, the test ILaunchBarListener captures all events and records the launch bar state at that time.
All those records are verified afterward.

@betamaxbandit betamaxbandit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tam, this is looking good. I think it could be merged now.
I only have one slight improvement for the test if you feel it would add value.

state.put(attr_activeDesc, descriptor);
state.put(attr_activeTarget, launchBarManagerMock.getActiveLaunchTarget());
state.put(attr_activeMode, launchBarManagerMock.getActiveLaunchMode());
launchBarState.get().add(state);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This now covers the state seen by all callbacks during the descriptor transition, which looks good.
One concern: the recorded state does not identify which callback produced it. Therefore launchBarStateTest_LaunchDescriptorChanged() could still pass if activeLaunchDescriptorChanged() were never fired, provided another callback populated the list. An empty list would also pass the assertions vacuously.
Could we record the event type as well and assert that the expected event was actually received? I don't think we need to assert event ordering, just that the expected callback occurred and that every callback saw the correct Launch Bar state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that a good point, especially

An empty list would also pass the assertions vacuously.

Had some thoughts on this one, and decided the create a TestLaunchBarListener object to make the event handling record more efficient.

Each event type will be record correspondingly and verified separately.

@DangMinhTam382 DangMinhTam382 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,
Thanks for the comments.
I updated the UT to cover for Event's type verification.

Could you have a look at it again and let me know what you think?

Thanks!

state.put(attr_activeDesc, descriptor);
state.put(attr_activeTarget, launchBarManagerMock.getActiveLaunchTarget());
state.put(attr_activeMode, launchBarManagerMock.getActiveLaunchMode());
launchBarState.get().add(state);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that a good point, especially

An empty list would also pass the assertions vacuously.

Had some thoughts on this one, and decided the create a TestLaunchBarListener object to make the event handling record more efficient.

Each event type will be record correspondingly and verified separately.

@betamaxbandit betamaxbandit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @Tam,

your latest change looks very good - thank you.

I'm sorry, but I only just noticed that your new test file does not have a copyright header.

Once you've added that, I think the change is ready to merge.

When active descriptor changed, and fireActiveLaunchDescriptorChanged()
is called, current active mode and target are out of sync. This puts
listeners at risk of handling event with false data for the changed
descriptor.

Changed it so that only fire event when related fields are finished
updating

@DangMinhTam382 DangMinhTam382 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi Mr. @betamaxbandit ,

Thanks for pointing this out.
I seem to keep forgetting this one.
The copyright header has been added.

Also, made this PR official as well.

Many thanks!

@DangMinhTam382
DangMinhTam382 marked this pull request as ready for review October 14, 2026 04:35

@betamaxbandit betamaxbandit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @DangMinhTam382
LGTM.
Thanks for fixing the copyright. I have no further comments.
However, I'd like @Kummallinen to give a final review because he did have a previous comment.

Also you mentioned there is a test failure and I understand that you are currently attempting to identify whether this is related to your change.

@betamaxbandit
betamaxbandit dismissed their stale review October 14, 2026 11:04

requested changes have no been made.

@DangMinhTam382

Copy link
Copy Markdown
Contributor Author

Hi Mr. @betamaxbandit ,
CC: @Kummallinen ,

Also you mentioned there is a test failure and I understand that you are currently attempting to identify whether this is related to your change.

That's correct.
Looking at the log, the test seems to be cancelled after a long timeout when running CBuildConfigurationManagerTests

2026-10-14T03:07:18.3083423Z Running org.eclipse.cdt.core.build.CBuildConfigurationManagerTests
2026-10-14T03:07:18.3702636Z Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
2026-10-14T03:07:18.5849449Z WARNING: A Java agent has been loaded dynamically (/home/runner/.m2/repository/p2/osgi/bundle/net.bytebuddy.byte-buddy-agent/1.18.15/net.bytebuddy.byte-buddy-agent-1.18.15.jar)
2026-10-14T03:07:18.5850399Z WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
2026-10-14T03:07:18.5851431Z WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
2026-10-14T03:07:18.5852019Z WARNING: Dynamic loading of agents will be disallowed by default in a future release
2026-10-14T03:07:18.5944392Z OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2026-10-14T05:03:13.8922975Z ##[error]The operation was canceled.
2026-10-14T05:03:13.8991651Z Post job cleanup.

So, I tried running it in my local dev environment and notice that a deadlock situation occurred at random rate (It passed sometime - looks like a racing condition case).
image
And apparently, with this PR changed, the deadlock happened more frequently.

Not entirely sure, the change's making the issue worst or more noticeable.
I will do more investigation on this matter.

@betamaxbandit

Copy link
Copy Markdown
Contributor

Hi Mr. @betamaxbandit , CC: @Kummallinen ,

Also you mentioned there is a test failure and I understand that you are currently attempting to identify whether this is related to your change.

That's correct. Looking at the log, the test seems to be cancelled after a long timeout when running CBuildConfigurationManagerTests

2026-10-14T03:07:18.3083423Z Running org.eclipse.cdt.core.build.CBuildConfigurationManagerTests
2026-10-14T03:07:18.3702636Z Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK. Please add Mockito as an agent to your build as described in Mockito's documentation: https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3
2026-10-14T03:07:18.5849449Z WARNING: A Java agent has been loaded dynamically (/home/runner/.m2/repository/p2/osgi/bundle/net.bytebuddy.byte-buddy-agent/1.18.15/net.bytebuddy.byte-buddy-agent-1.18.15.jar)
2026-10-14T03:07:18.5850399Z WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
2026-10-14T03:07:18.5851431Z WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
2026-10-14T03:07:18.5852019Z WARNING: Dynamic loading of agents will be disallowed by default in a future release
2026-10-14T03:07:18.5944392Z OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2026-10-14T05:03:13.8922975Z ##[error]The operation was canceled.
2026-10-14T05:03:13.8991651Z Post job cleanup.

So, I tried running it in my local dev environment and notice that a deadlock situation occurred at random rate (It passed sometime - looks like a racing condition case). image And apparently, with this PR changed, the deadlock happened more frequently.

Not entirely sure, the change's making the issue worst or more noticeable. I will do more investigation on this matter.

Hi @DangMinhTam382 ,

I had a quick look at this issue and tests around it. I didn't come up with any silver bullets, I'm wondering if what this test is doing could be a clue or help?

@DangMinhTam382
DangMinhTam382 marked this pull request as draft October 16, 2026 12:13
@DangMinhTam382

Copy link
Copy Markdown
Contributor Author

Hi Mr. @betamaxbandit,
CC: Mr. @Kummallinen

Thanks for the suggestion on the waitForLaunchBarTracker();.
It does help with the UT and make it stable.

Though, this not going to be the suitable fix, as it happens in multiple Test class. Fixing for each of them is not an option here.
So, I've investigated it and come up with a different approach in #1534

Also, had a theory on how this PR impact the other UT: (#1533 (comment))

The main noticeable difference is that PR 1486 delays the notification sent by LaunchBarManager to CoreBuildLaunchBarTracker. This could potentially reduce the time gap between the two call flows above, making the race condition more likely to occur.

There's more information on the issue.
I mentioned you there, if you have a moment, please help me have a quick look at it.

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants