@@ -87,7 +87,7 @@ public class Jooby implements Router, Registry {
8787
8888 private static Jooby owner ;
8989 private static ExecutionMode BOOT_EXECUTION_MODE = ExecutionMode .DEFAULT ;
90- private static Server BOOT_SERVER ;
90+ private static BufferedOutputFactory BUFFER_FACTORY ;
9191
9292 private RouterImpl router ;
9393
@@ -121,8 +121,6 @@ public class Jooby implements Router, Registry {
121121
122122 private String version ;
123123
124- private Server server ;
125-
126124 /** Creates a new Jooby instance. */
127125 public Jooby () {
128126 if (owner == null ) {
@@ -133,14 +131,10 @@ public Jooby() {
133131 startingCallbacks = new ArrayList <>();
134132 readyCallbacks = new ArrayList <>();
135133 lateExtensions = new ArrayList <>();
136- server = BOOT_SERVER ;
137- if (server != null ) {
138- router .setOutputFactory (server .getOutputFactory ());
139- } else {
140- // NOTE: fallback to default, this is required for direct instance creation of class
141- // app bootstrap always ensures server instance.
142- router .setOutputFactory (BufferedOutputFactory .create ());
143- }
134+ // NOTE: fallback to default, this is required for direct instance creation of class
135+ // app bootstrap always ensures server instance.
136+ router .setOutputFactory (
137+ Optional .ofNullable (BUFFER_FACTORY ).orElseGet (BufferedOutputFactory ::create ));
144138 } else {
145139 copyState (owner , this );
146140 }
@@ -1311,12 +1305,12 @@ public static Jooby createApp(
13111305
13121306 Jooby app ;
13131307 try {
1314- Jooby .BOOT_SERVER = server ;
1308+ Jooby .BUFFER_FACTORY = server . getOutputFactory () ;
13151309 Jooby .BOOT_EXECUTION_MODE = executionMode ;
13161310 app = provider .get ();
13171311 } finally {
13181312 Jooby .BOOT_EXECUTION_MODE = executionMode ;
1319- Jooby .BOOT_SERVER = null ;
1313+ Jooby .BUFFER_FACTORY = null ;
13201314 }
13211315
13221316 return app ;
@@ -1452,7 +1446,7 @@ private void joobyRunHook(ClassLoader loader, Server server) {
14521446 }
14531447
14541448 /**
1455- * Copy internal state from one application into other .
1449+ * Copy the internal state from one application into others .
14561450 *
14571451 * @param source Source application.
14581452 * @param dest Destination application.
@@ -1471,6 +1465,5 @@ private static void copyState(Jooby source, Jooby dest) {
14711465 dest .readyCallbacks = source .readyCallbacks ;
14721466 dest .startingCallbacks = source .startingCallbacks ;
14731467 dest .stopCallbacks = source .stopCallbacks ;
1474- dest .server = source .server ;
14751468 }
14761469}
0 commit comments