Bug 582511 - RepositorySearchDialog.findGitDirsRecursive(RepositorySearchDialog.java:448) beginTask should only be called once
Summary: RepositorySearchDialog.findGitDirsRecursive(RepositorySearchDialog.java:448) ...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 6.8   Edit
Assignee: Thomas Wolf CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-05 10:05 EDT by Lars Vogel CLA
Modified: 2023-10-14 11:57 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2023-10-05 10:05:25 EDT
Using EGit nightly I see the following. I think Joerg fixed a similar issue before in EGit.


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:428)
	at org.eclipse.egit.ui.internal.repository.RepositorySearchDialog.findGitDirsRecursive(RepositorySearchDialog.java:448)
	at org.eclipse.egit.ui.internal.repository.RepositorySearchDialog$10.run(RepositorySearchDialog.java:619)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: java.lang.IllegalStateException: beginTask(Searching, -1) was called here previously
	at org.eclipse.jface.operation.AccumulatingProgressMonitor.beginTask(AccumulatingProgressMonitor.java:155)
	at org.eclipse.egit.ui.internal.repository.RepositorySearchDialog$10.run(RepositorySearchDialog.java:615)
	... 1 more
Comment 1 Erik Brangs CLA 2023-10-06 03:37:28 EDT
I saw the same stack trace in 2023-12 M1. In my case, it happened when adding an existing local repository to the view. It seems to happen immediately after selecting "Add a Git repository..." from the right-click menu in the "Git Repositories" tab in the Git perspective.
Comment 2 Thomas Wolf CLA 2023-10-14 05:43:18 EDT
Just switch that trace flag off. (I think it is off by default now.) The code is working perfectly fine.

IMO SubMonitor is broken. If this rule about beginTask is enforced, then SubMonitor.convert(IProgressMonitor) and SubMonitor.convert(IProgressMonitor, int) become useless since in general the caller cannot be sure whether beginTask was already called on the passed monitor. And in particular that will always be the case if the passed monitor is a SubMonitor.

Either drop this somewhat artificial rule, or make sure that the SubMonitor.convert(...) variants do not call beginTask if the given monitor is a SubMonitor, but call setTaskName() and setWorkRemaining() directly (if a name or ticks are given).
Comment 3 Thomas Wolf CLA 2023-10-14 11:57:02 EDT
https://git.eclipse.org/r/c/egit/egit/+/204918