Bug 567000 - Replace SubProgressMonitor by SubMonitor in org.eclipse.core.internal.utils.Policy
Summary: Replace SubProgressMonitor by SubMonitor in org.eclipse.core.internal.utils.P...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.17   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-15 09:21 EDT by Christopher Gerking CLA
Modified: 2020-09-15 09:26 EDT (History)
0 users

See Also:


Attachments
Policy patch (1.19 KB, patch)
2020-09-15 09:26 EDT, Christopher Gerking CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Gerking CLA 2020-09-15 09:21:22 EDT
The deprecated SubProgressMonitor is still used in org.eclipse.core.internal.utils.Policy and should be replaced by SubMonitor. 

Conversion seems easy, but care has to be taken that the contract of SubMonitor will not be violated. In particular, beginTask(...) must not be called more than once on each SubMonitor. Therefore, excessive use of SubMonitor.convert(...) needs to be avoided, as it calls beginTask(...) internally.
Comment 1 Christopher Gerking CLA 2020-09-15 09:26:32 EDT
Created attachment 284136 [details]
Policy patch

The patch does the conversion to SubMonitor only once for each monitor, thereby preventing the above contract violations. 

Changing the return types from IProgressMonitor to SubMonitor should be consistent with the Liskov substitution principle.

The code uses SubMonitor.newChild(...) instead of split(...) to preserve the current behavior without checking for cancellation. If these checks are desirable, use split(...) instead.