File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
java/server/src/org/openqa/selenium/grid/node/local Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 18
18
package org .openqa .selenium .grid .node .local ;
19
19
20
20
import com .google .common .collect .ImmutableList ;
21
+
21
22
import org .openqa .selenium .Capabilities ;
22
23
import org .openqa .selenium .grid .config .Config ;
23
24
import org .openqa .selenium .grid .data .DefaultSlotMatcher ;
@@ -91,7 +92,18 @@ private static Collection<SessionFactory> createSessionFactory(
91
92
builders .stream ()
92
93
.filter (builder -> builder .score (stereotype ) > 0 )
93
94
.forEach (builder -> {
94
- DriverService .Builder <?, ?> driverServiceBuilder = builder .usingAnyFreePort ();
95
+ DriverService .Builder <?, ?> driverServiceBuilder ;
96
+ Class <?> clazz = builder .getClass ();
97
+ try {
98
+ // We do this to give each Node slot its own instance of the DriverService.Builder.
99
+ // This is important because the Node processes many new session requests
100
+ // and the DriverService creation needs to be thread safe.
101
+ Object driverBuilder = clazz .newInstance ();
102
+ driverServiceBuilder = ((DriverService .Builder <?, ?>) driverBuilder ).usingAnyFreePort ();
103
+ } catch (InstantiationException | IllegalAccessException e ) {
104
+ throw new IllegalArgumentException (String .format (
105
+ "Class %s could not be found or instantiated" , clazz ));
106
+ }
95
107
toReturn .add (new DriverServiceSessionFactory (
96
108
tracer ,
97
109
clientFactory ,
You can’t perform that action at this time.
0 commit comments