-
Notifications
You must be signed in to change notification settings - Fork 147
Fix incorrect SubMonitor usage patterns #2274
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
base: master
Are you sure you want to change the base?
Fix incorrect SubMonitor usage patterns #2274
Conversation
c06f361 to
0da857c
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. |
Test Results 1 872 files - 81 1 872 suites - 81 1h 22m 18s ⏱️ - 1m 22s For more details on these failures and errors, see this check. Results for commit e39b98b. ± Comparison against base commit 3e8e40e. This pull request removes 153 tests.♻️ This comment has been updated with latest results. |
This commit addresses several SubMonitor anti-patterns identified
throughout the codebase, based on best practices from the Eclipse
article on Progress Monitors.
Changes made:
1. Remove unnecessary null checks before SubMonitor.convert()
- SubMonitor.convert() can handle null monitors
- Fixed in team Policy.java files (core and ui)
2. Remove unnecessary SubMonitor.done() calls
- SubMonitor.done() is a no-op and should not be called
- Removed 27 instances across resources and team bundles:
* org.eclipse.core.filesystem: LocalFile.java (2 calls)
* org.eclipse.core.resources: File.java (6), Folder.java (1),
Project.java (3), SaveManager.java (4), Workspace.java (7)
* org.eclipse.compare.core: RangeComparatorLCS.java (1)
* org.eclipse.compare: AddFromHistoryAction.java (1)
* org.eclipse.team.core: BundleImporterDelegate.java (1),
Subscriber.java (1)
3. Remove redundant cancellation checks before split()
- SubMonitor.split() already checks for cancellation
- Fixed in AutoBuildJob.java
Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
f1091b3 to
b39c458
Compare
The previous implementation used SubMonitor.convert(monitor, ticks) which internally calls beginTask(), causing "beginTask may only be called once" errors when the returned monitor is passed to code that also calls beginTask(). The correct pattern is SubMonitor.convert(monitor).split(ticks), which creates a child monitor without calling beginTask on it, allowing the caller to call beginTask as needed. This fixes test failures where FussyProgressMonitor detected multiple beginTask calls (e.g., "beginTask may only be called once (old name=Opening 'MyProject'.)"). Files changed: - resources/bundles/org.eclipse.core.resources/.../Policy.java - team/bundles/org.eclipse.team.core/.../Policy.java - team/bundles/org.eclipse.team.ui/.../Policy.java - team/bundles/org.eclipse.jsch.core/.../Policy.java 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses several SubMonitor anti-patterns identified throughout the codebase, based on best practices from the Eclipse article on Progress Monitors.
Changes made:
Remove unnecessary null checks before SubMonitor.convert()
Remove unnecessary SubMonitor.done() calls
Remove redundant cancellation checks before split()
Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html