eclipse-platform / eclipse-platform/eclipse.platform
Expose API to allow querying for Workspace lock
- Dominant language
- Java
- Stars
- 165
- Forks
- 174
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 22
Description
I believe there is value in having an API to check whether the current thread owns the workspace lock. This would allow implementing something like deadlock prevention as a safeguard.
Right now it is possible using internals:
```
var workspace = ResourcesPlugin.getWorkspace();
try {
if (((Workspace) workspace).getWorkManager().isLockAlreadyAcquired()) {
throw new IllegalStateException(format(
"The current thread (%s) already owns the workspace lock. Calling get() will almost certainly cause a deadlock!",
Thread.currentThread()));
}
} catch (CoreException e) {
throw new IllegalStateException("The workspace is shutdown!", e);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.