Repository navigation
Fix NPE in DocumentMerger.doDiff #123 - #2990
ravnskjaer wants to merge 2 commits into
Conversation
5098d7c to
693ea16
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The timing-sensitive fix lacks a deterministic regression test covering the reported race.
1 open finding
What changed in this PR
Prevents duplicate compare content trees and the resulting DocumentMerger NPE during asynchronous initialization.
Changes:
- Detects re-entrant control creation.
- Skips duplicate content creation while a control is already being built.
| File | Description |
|---|---|
CompareEditor.java |
Guards the initialization callback against duplicate compare controls. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
693ea16 to
54edb62
Compare
|
@iloveeclipse I’ve added the regression test Copilot asked for (CompareEditorOpenRaceTest). The GitHub workflows are awaiting approval, and the Jenkins build timed out for this PR too. Could you approve the workflows and retrigger Jenkins? |
54edb62 to
e68f885
Compare
|
Thanks for retriggering, @iloveeclipse, all checks are green now and the Copilot finding is addressed with the new regression test. Could you take a look and merge if it looks good to you? |
|
@iloveeclipse sorry to bother you again - if you don't have the time, can you maybe direct me to someone else who can review it? |
e68f885 to
8260564
Compare
|
Thanks @iloveeclipse - Copilot seems satisfied now :) anything else needed from my side on this one? |
|
Friendly ping @iloveeclipse - if you don't have the time could you maybe point me to someone else? I am sorry if this is considered as spam, I am not aware of the process of reviewing and accepting PRs so I don't know what the expected waiting time is for a PR like this. |
|
Thank you for the fix. I ran CompareEditorOpenRaceTest on Linux with and without the change to CompareEditor: it passes with the fix and fails without it (createContents called twice). I plan to merge this later today. |
|
Just learned that we are in M3 so I will not merge this, next window for merging for me without additional committer approval will be once the next release opens up. |
8260564 to
a99178e
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
|
@vogella I rebased this on the current master (the bot added the version bump for org.eclipse.compare) and all checks are green. Could you merge it when you have a moment? Thanks! |
|
Code change still looks good to me, only the Javadoc is too long, AI engines like to write to much, please ask to make it concise or shorten it yourself. |
25079b8 to
43cc0f3
Compare
|
@vogella thanks! I shortened the Javadoc and comments and left the code unchanged. |
|
Looking more closely at
|
|
Thanks for the detailed look! |
43cc0f3 to
71f55de
Compare
The compare result is set before the initialization job has finished, because the job prefetches the contents afterwards. If the "still initializing" timer fired in between, createCompareControl() already created the contents, and the job's syncExec, dispatched by the event loop during that creation, created them a second time. The orphaned content tree's viewer later diffed against a disposed input. Only create the contents once the job has finished. Fixes eclipse-platform#123
71f55de to
38d2f6b
Compare
|
@vogella thanks for the detailed review! I reworked the fix as you suggested: The control is now only created by the finished initialization job: This also fits with #2795: previously the timer could create the viewers before the prefetch was done, so they read the streams on the UI thread again. Now they always get the prefetched contents. The stale-job problem (your point 1) is tracked separately in #3096. I also rebased onto the current master, since the old base made the org.eclipse.core.resources baseline check fail. The remaining Windows failure is the known |
|
Please include the fix for #3096 also in this PR. Splitting it, just make it unecessary time-consuming for me to test and review. |
When a reused compare editor switched to another input while the job of the previous input was still running, that job's syncExec still applied its outcome to the new input: it could register the new input's saveables too early, set the state to the old job's result (usually CANCELED) and close the editor. The syncExec now does nothing when the editor input has changed in the meantime. The test class is renamed, as it now covers both cases. Fixes eclipse-platform#3096


Contents created twice (#123)
The "still initializing" timer and the initialization job could both create the contents of the same compare editor input. The compare result is set before the job has finished, because the job prefetches the contents afterwards, so the timer already created the contents while the job was still running, and the job's syncExec then created them a second time. One of the two content trees stayed alive when the editor switched to another input, and its viewer later diffed against the disposed input.
The contents are now only created once the initialization job has finished.
Stale job after an input switch (#3096)
When a reused compare editor switched to another input while the previous input's job was still running, that job's syncExec still applied its outcome to the new input, and could close the editor. The syncExec now does nothing when the editor input has changed in the meantime.
Tests
CompareEditorInitializationTestcovers both cases: no contents are created while the job is running, even after the timer has fired, and a stale job doesn't affect the new input. Both tests fail without the respective fix.Fixes #123
Fixes #3096