-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap the managed worker thread pool to disallow shutdown by applicati…
- Loading branch information
1 parent
b8c5a62
commit 68822e5
Showing
5 changed files
with
103 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/runtime/src/main/java/io/quarkus/runtime/util/ForwardingScheduledExecutorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkus.runtime.util; | ||
|
||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Forwards all method calls to the scheduled executor service returned from the {@link #delegate()} method. Only non-default | ||
* methods | ||
* declared on the {@link ScheduledExecutorService} interface are forwarded. | ||
*/ | ||
public abstract class ForwardingScheduledExecutorService extends ForwardingExecutorService implements ScheduledExecutorService { | ||
|
||
protected abstract ScheduledExecutorService delegate(); | ||
|
||
@Override | ||
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { | ||
return delegate().schedule(command, delay, unit); | ||
} | ||
|
||
@Override | ||
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { | ||
return delegate().schedule(callable, delay, unit); | ||
} | ||
|
||
@Override | ||
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { | ||
return delegate().scheduleAtFixedRate(command, initialDelay, period, unit); | ||
} | ||
|
||
@Override | ||
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { | ||
return delegate().scheduleWithFixedDelay(command, initialDelay, delay, unit); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
core/runtime/src/main/java/io/quarkus/runtime/util/NoopShutdownScheduledExecutorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.quarkus.runtime.util; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* Forwards all method calls to the scheduled executor service returned from the {@link #delegate()} method. | ||
* Does not allow shutdown | ||
*/ | ||
public class NoopShutdownScheduledExecutorService extends ForwardingScheduledExecutorService { | ||
|
||
private static final Logger LOG = Logger.getLogger(NoopShutdownScheduledExecutorService.class); | ||
|
||
private final ScheduledExecutorService delegate; | ||
|
||
public NoopShutdownScheduledExecutorService(final ScheduledExecutorService delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
protected ScheduledExecutorService delegate() { | ||
return delegate; | ||
} | ||
|
||
@Override | ||
public boolean isShutdown() { | ||
// managed executors are never shut down from the application's perspective | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isTerminated() { | ||
// managed executors are never shut down from the application's perspective | ||
return false; | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
LOG.debug("shutdown() not allowed on managed executor service"); | ||
} | ||
|
||
@Override | ||
public List<Runnable> shutdownNow() { | ||
LOG.debug("shutdownNow() not allowed on managed executor service"); | ||
return List.of(); | ||
} | ||
|
||
} |
39 changes: 0 additions & 39 deletions
39
...ertx/runtime/src/main/java/io/quarkus/vertx/core/runtime/NoopShutdownExecutorService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters