- class CloseableEventExecutorMixin implements AutoCloseable {
- public static final int DEFAULT_SHUTDOWN_SECONDS = 1;
- private final EventExecutor eventExecutor;
-
- public CloseableEventExecutorMixin(final EventExecutor eventExecutor) {
- this.eventExecutor = eventExecutor;
- }
-
- @Override
- @SuppressFBWarnings(value = "UC_USELESS_VOID_METHOD", justification = "False positive")
- public void close() {
- eventExecutor.shutdownGracefully(0, DEFAULT_SHUTDOWN_SECONDS, TimeUnit.SECONDS);
- }
-
- static AutoCloseableEventExecutor createCloseableProxy(final EventExecutor eventExecutor) {
- final CloseableEventExecutorMixin closeableEventExecutor = new CloseableEventExecutorMixin(eventExecutor);
- return Reflection.newProxy(AutoCloseableEventExecutor.class, new AbstractInvocationHandler() {
- @Override
- protected Object handleInvocation(final Object proxy, final Method method, final Object[] args)
- throws Throwable {
- if (method.getName().equals("close")) {
- closeableEventExecutor.close();
- return null;
- } else {
- return method.invoke(closeableEventExecutor.eventExecutor, args);
- }
+ private static AutoCloseableEventExecutor createCloseableProxy(final EventExecutor eventExecutor) {
+ return Reflection.newProxy(AutoCloseableEventExecutor.class, new AbstractInvocationHandler() {
+ @Override
+ protected Object handleInvocation(final Object proxy, final Method method, final Object[] args)
+ throws Throwable {
+ if (method.getName().equals("close")) {
+ eventExecutor.shutdownGracefully(0, 1, TimeUnit.SECONDS);
+ return null;
+ } else {
+ return method.invoke(eventExecutor, args);