Use common non-magic number for shutdown timeout
Motivation: AbstractEventExecutor and AbstractEventExecutorGroup have hard-coded magic timeout numbers. They should have the same timeout numbers, but it's easy to break that rule because they are hard-coded in each place. Modifications: Add package private constants to AbstractEventExecutor and let AbstractEventExecutorGroup use them. Result: Single timeout change affects two classes.
This commit is contained in:
parent
007694b963
commit
4332821e6f
@ -29,6 +29,9 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public abstract class AbstractEventExecutor extends AbstractExecutorService implements EventExecutor {
|
||||
|
||||
static final long DEFAULT_SHUTDOWN_QUIET_PERIOD = 2;
|
||||
static final long DEFAULT_SHUTDOWN_TIMEOUT = 15;
|
||||
|
||||
private final EventExecutorGroup parent;
|
||||
|
||||
protected AbstractEventExecutor() {
|
||||
@ -61,7 +64,7 @@ public abstract class AbstractEventExecutor extends AbstractExecutorService impl
|
||||
|
||||
@Override
|
||||
public Future<?> shutdownGracefully() {
|
||||
return shutdownGracefully(2, 15, TimeUnit.SECONDS);
|
||||
return shutdownGracefully(DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,8 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import static io.netty.util.concurrent.AbstractEventExecutor.*;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link EventExecutorGroup} implementations.
|
||||
@ -66,7 +68,7 @@ public abstract class AbstractEventExecutorGroup implements EventExecutorGroup {
|
||||
|
||||
@Override
|
||||
public Future<?> shutdownGracefully() {
|
||||
return shutdownGracefully(2, 15, TimeUnit.SECONDS);
|
||||
return shutdownGracefully(DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user