Bug 582435 - "IllegalStateException: beginTask should only be called once per instance" error on diff
Summary: "IllegalStateException: beginTask should only be called once per instance" er...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 6.8   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-19 08:47 EDT by Andrey Loskutov CLA
Modified: 2023-09-21 03:20 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2023-09-19 08:47:00 EDT
See https://github.com/eclipse-platform/eclipse.platform.ui/issues/1125

After adding extra checks to the monitors in the new 4.30 platform, we see following waring reported every time a git diff is called in Eclipse (e.g. from History view):

eclipse.buildId=4.30.0.I20230918-1800
java.version=17.0.6-internal

org.eclipse.jface
Warning
Tue Sep 19 11:47:27 CEST 2023
beginTask should only be called once per instance. At least call done() before further invocations

java.lang.IllegalStateException: beginTask should only be called once per instance. At least call done() before further invocations
	at org.eclipse.jface.operation.AccumulatingProgressMonitor.beginTask(AccumulatingProgressMonitor.java:148)
	at org.eclipse.core.runtime.SubMonitor.convert(SubMonitor.java:483)
	at org.eclipse.core.runtime.SubMonitor.convert(SubMonitor.java:449)
	at org.eclipse.egit.core.synchronize.GitSyncCache.mergeAllDataIntoCache(GitSyncCache.java:68)
	at org.eclipse.egit.core.synchronize.GitSyncCache.getAllData(GitSyncCache.java:61)
	at org.eclipse.egit.core.synchronize.GitSyncCache.getAllData(GitSyncCache.java:54)
	at org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber.init(GitResourceVariantTreeSubscriber.java:105)
	at org.eclipse.egit.ui.internal.synchronize.ModelAwareGitSynchronizer.createResourceMappingContext(ModelAwareGitSynchronizer.java:218)
	at org.eclipse.egit.ui.internal.synchronize.ModelAwareGitSynchronizer$2.run(ModelAwareGitSynchronizer.java:101)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.lang.IllegalStateException: beginTask(Fetching data from git repositories, 1) was called here previously
	at org.eclipse.jface.operation.AccumulatingProgressMonitor.beginTask(AccumulatingProgressMonitor.java:155)
	at org.eclipse.egit.core.synchronize.GitResourceVariantTreeSubscriber.init(GitResourceVariantTreeSubscriber.java:101)
	... 3 more

The problem is that progress monitor API / use is highly inconsistent and AccumulatingProgressMonitor didn't care before if task was created multiple times (which shouldn't happen).

I will provide a patch.