Fix Issue576 unit test.
package org.jooby.internal;
import com.google.common.util.concurrent.MoreExecutors;
+import com.google.inject.Inject;
import org.jooby.spi.Server;
-import javax.inject.Inject;
import javax.inject.Provider;
import java.util.concurrent.Executor;
@@ -32,9 +32,12 @@ public class ServerExecutorProvider implements Provider<Executor> {
private Executor executor;
@Inject
- public ServerExecutorProvider(final Server server) {
- executor = requireNonNull(server, "Server is required.")
- .executor().orElse(MoreExecutors.directExecutor());
+ public ServerExecutorProvider(final ServerHolder serverHolder) {
+ requireNonNull(serverHolder, "Server holder is required.");
+
+ executor = (serverHolder.server != null) ?
+ serverHolder.server.executor().orElse(MoreExecutors.directExecutor()) :
+ MoreExecutors.directExecutor();
}
@Override
@@ -42,4 +45,10 @@ public class ServerExecutorProvider implements Provider<Executor> {
return executor;
}
+ static class ServerHolder {
+
+ @Inject(optional = true) Server server = null;
+
+ }
+
}
