assertj / assertj/assertj-swing
Pause object has a static ExecutorService that can't be shutdown
- Vorherrschende Sprache
- Java
- Sterne
- 121
- Forks
- 52
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
`org.assertj.swing.timing.Pause` has an ExecutorService. It's static and cannot be closed. It means that we have non-daemon threads hanging in there and preventing the JVM to finish.
An example is
```java
public static void main(String[] args) throws Exception {
Pause.pause(new Condition("Cond") {
@Override
public boolean test() {
return true;
}
});
Field field = Pause.class.getDeclaredField("EXECUTOR_SERVICE");
field.setAccessible(true);
ExecutorService service = (ExecutorService) field.get(null);
service.shutdownNow();
}
```
Without the reflection code at the end, it won't exit for a while.
The easiest solution is to add a static `close()` method to shutdown the pool. But I think the best is to change the code to rely on the commonPool, e.g. `ForkJoinPool.commonPool().submit()` or a CompletableFuture.
Beitragsleitfaden
Rechercherichtung
Lies org.assertj.swing.timing.Pause und verfolge den Lebenszyklus seines statischen EXECUTOR_SERVICE. Reproduziere das Problem mit der Beispiel-Main-Methode und wähle und validiere anschließend einen Shutdown- oder Common-Pool-Ansatz; fertig ist es, wenn das Beispiel ohne Reflection und ohne verbleibende Nicht-Daemon-Threads beendet werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100