Skip to content

Commit 49b3e3e

Browse files
committed
Fix temporary workspace deletion on JVM shutdown (#967)
Initial attempt missed to shutdown the Eclipse Job manager.
1 parent 2d3acde commit 49b3e3e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

_ext/eclipse-base/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.2.1`).
44

55
## [Unreleased]
6+
### Fixed
7+
* Racing condition when cleaning up temporary workspace on JVM runtime shutdown (see [#967](https://github.com/diffplug/spotless/issues/967)). Can lead to error logs and remaining files in workspace.
68

79
## [3.5.1] - 2021-10-16
810
### Fixed
9-
* Racing condition when cleaning up temporary workspace on JVM runtime shutdown (see [#967](https://github.com/diffplug/spotless/issues/967)). Can lead to error logs and remaining files in workspace.
11+
* ~~Racing condition when cleaning up temporary workspace on JVM runtime shutdown (see [#967](https://github.com/diffplug/spotless/issues/967)). Can lead to error logs and remaining files in workspace.~~
1012

1113
## [3.5.0] - 2021-06-20
1214
### Added

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.function.Function;
2222

23+
import org.eclipse.core.internal.jobs.JobManager;
2324
import org.eclipse.osgi.internal.location.LocationHelper;
2425
import org.osgi.framework.Bundle;
2526
import org.osgi.framework.BundleActivator;
@@ -80,7 +81,16 @@ public BundleController() throws BundleException {
8081
FrameworkBundleRegistry.initialize(this);
8182
}
8283

84+
/**
85+
* Stop {@link org.eclipse.core.internal.jobs.JobManager} worker pool
86+
* and clean up resources of Spotless bundles and services.
87+
*
88+
* @implNote The {@link org.osgi.framework.BundleActivator}s
89+
* are not stopped, since they are not completely started.
90+
* For example services are suppressed by {@link StaticBundleContext}.
91+
*/
8392
public void shutdown() {
93+
JobManager.shutdown();
8494
bundles.getAll().forEach(b -> {
8595
try {
8696
b.stop();
@@ -109,7 +119,7 @@ public void addBundle(int bundleState, BundleActivator activator, Function<Bundl
109119
}
110120
}
111121

112-
/** Adds new bundel whithout activator (e.g. used for ony for extensions) */
122+
/** Adds new bundel whithout activator (e.g. used for only for extensions) */
113123
public void addBundle(Class<?> clazzInBundleJar, Function<Bundle, BundleException> register) throws BundleException {
114124
BundleContext contextFacade = new BundleControllerContextFacade(this, clazzInBundleJar);
115125
bundles.add(contextFacade.getBundle());

0 commit comments

Comments
 (0)