Skip to content

Remove redundant progress monitor done() calls#2340

Draft
vogella wants to merge 1 commit into
eclipse-pde:masterfrom
vogella:cleanup-submonitor-antipatterns
Draft

Remove redundant progress monitor done() calls#2340
vogella wants to merge 1 commit into
eclipse-pde:masterfrom
vogella:cleanup-submonitor-antipatterns

Conversation

@vogella
Copy link
Copy Markdown
Contributor

@vogella vogella commented May 18, 2026

SubMonitor.done() is effectively a no-op in well-formed code because the parent SubMonitor.convert call already manages parent ticks. Where the only purpose of a try/finally block was to call done(), the block has been removed and the body de-indented.

Calling done() on the raw IProgressMonitor parameter is also an antipattern: only the code that created the monitor is supposed to call done() on it. That covers Job.run overrides (the Jobs framework already does it) and methods that receive a monitor from a caller (the caller owns its lifecycle). In TargetPlatformPreferencePage.LoadDefaultTargetJob the SubMonitor was created but never used to report progress, so the convert call and its now-unused import are removed too.

Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html

Planned for 4.41

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

Test Results

  126 files  ±0    126 suites  ±0   36m 59s ⏱️ + 1m 54s
3 510 tests ±0  3 451 ✅  - 5   54 💤 ±0  5 ❌ +5 
9 333 runs  ±0  9 198 ✅  - 5  130 💤 ±0  5 ❌ +5 

For more details on these failures, see this check.

Results for commit 13cf067. ± Comparison against base commit 4f1f320.

♻️ This comment has been updated with latest results.

SubMonitor.done() is effectively a no-op in well-formed code: the
parent SubMonitor.convert call already manages parent ticks, so
explicit done() on a SubMonitor is unnecessary. Where the only
purpose of a try/finally block was to call done(), the block has
been removed and the body de-indented.

Likewise, calling done() on the raw IProgressMonitor parameter is
an antipattern: only the code that created the monitor is supposed
to call done() on it. This affects Job.run overrides (where the
Jobs framework already invokes done()) and methods that receive a
monitor from a caller (where the caller owns its lifecycle), so
the calls in TargetPlatformPreferencePage.LoadDefaultTargetJob and
AbstractBundleContainer.resolve have been removed too.

In TargetPlatformPreferencePage.LoadDefaultTargetJob the SubMonitor
was created but never used to report progress, so the convert call
and its now-unused import are removed as well.

Reference: https://www.eclipse.org/articles/Article-Progress-Monitors/article.html
@vogella vogella force-pushed the cleanup-submonitor-antipatterns branch from a1ae1ca to 13cf067 Compare May 18, 2026 15:33
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.

1 participant