eclipse-platform / eclipse-platform/eclipse.platform

Job framework become unusable after stopping and restarting the "org.eclipse.core.jobs" bundle

Aperta
#2,783 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Java
Stelle
165
Fork
174
Merge medio
2g 8h
PR unite (30g)
22

Descrizione

Let's make sure issue is not already fixed in latest builds first.

- [x] I verified I can reproduce this issue against [latest Integration Build of Eclipse SDK](https://download.eclipse.org/eclipse/downloads/)

Not checked with the latest Build, but checked that the affected bundle has been unchanged compared to the version I tried with.

## Steps to reproduce

* In a running application, stop the "org.eclipse.core.jobs" bundle
* restart the bundle
* create a new job

This fails with an exception

I expected: That the bundle can be stopped and restarted

But got: it becomes unusable after restarting

Looking at the failing code, it looks like the class "InternalJob" keeps a cached instance of the first ever created JobManager in a static final field and only uses that for all created instances of InternalJob instead of using the current running JobManager.

## Here is some relevant log output

From `/.metadata/.log`

```java
Command-line arguments: -application eclipse-core-jobs-sample.id1 -data W:\fis\ws\fa_99.99.0/../runtime-eclipse-core-jobs-sample.id1 -dev file:///W:/fis/ws/fa_99.99.0/.metadata/.plugins/org.eclipse.pde.core/eclipse-core-jobs-sample.id1/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.osgi 4 0 2026-06-28 11:40:00.218
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Job manager has been shut down.
at org.eclipse.core.internal.jobs.JobManager.scheduleInternal(JobManager.java:1485)
at org.eclipse.core.internal.jobs.JobManager.lambda$5(JobManager.java:1475)
at org.eclipse.core.internal.jobs.JobManager.withWriteLock(JobManager.java:568)
at org.eclipse.core.internal.jobs.JobManager.schedule(JobManager.java:1474)
at org.eclipse.core.internal.jobs.InternalJob.schedule(InternalJob.java:402)
at org.eclipse.core.runtime.jobs.Job.schedule(Job.java:654)
at sample.Application.start(Application.java:35)
```

## Code for reproduction
```java
BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();

Bundle coreJobs = Arrays.stream( bundleContext.getBundles()).filter(x -> x.getSymbolicName().equals("org.eclipse.core.jobs")).findFirst().orElseThrow();

coreJobs.stop();

coreJobs.start();

Job job = new Job("test") {

@Override
protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}
};
job.schedule();
```

## Tested under this environment:
* OS & version: Windows, 11
* Eclipse IDE/Platform version (as shown in *Help > About*): Eclipse 25-12

## Community

- [x] I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci la sequenza di arresto e riavvio del bundle org.eclipse.core.jobs, quindi inizia da org.eclipse.core.internal.jobs.InternalJob e JobManager, in particolare dal percorso di scheduling mostrato nello stack trace. Verifica come viene rappresentato il bundle riavviato quando viene pianificato un nuovo Job. Il lavoro è completato quando è possibile creare e pianificare un Job dopo il riavvio del bundle, con una copertura di regressione per la sequenza segnalata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
75/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.