Bug 567000

Summary: Replace SubProgressMonitor by SubMonitor in org.eclipse.core.internal.utils.Policy
Product: [Eclipse Project] Platform Reporter: Christopher Gerking <christopher.gerking>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3    
Version: 4.17   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:
Attachments:
Description Flags
Policy patch none

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.