17
17
18
18
package org .openqa .selenium .grid .sessionqueue ;
19
19
20
- import org .openqa .selenium .Capabilities ;
21
- import org .openqa .selenium .SessionNotCreatedException ;
22
20
import org .openqa .selenium .grid .data .RequestId ;
23
21
import org .openqa .selenium .grid .security .RequiresSecretFilter ;
24
22
import org .openqa .selenium .grid .security .Secret ;
25
23
import org .openqa .selenium .internal .Require ;
26
- import org .openqa .selenium .remote .NewSessionPayload ;
27
24
import org .openqa .selenium .remote .http .HttpRequest ;
28
25
import org .openqa .selenium .remote .http .HttpResponse ;
29
26
import org .openqa .selenium .remote .http .Routable ;
30
27
import org .openqa .selenium .remote .http .Route ;
31
- import org .openqa .selenium .remote .tracing .AttributeKey ;
32
- import org .openqa .selenium .remote .tracing .EventAttribute ;
33
- import org .openqa .selenium .remote .tracing .EventAttributeValue ;
34
- import org .openqa .selenium .remote .tracing .Span ;
35
28
import org .openqa .selenium .remote .tracing .Tracer ;
36
29
import org .openqa .selenium .status .HasReadyState ;
37
30
38
- import java .io .IOException ;
39
- import java .io .Reader ;
40
- import java .util .HashMap ;
41
- import java .util .Iterator ;
42
31
import java .util .List ;
43
32
import java .util .Map ;
44
- import java .util .Objects ;
45
33
import java .util .Optional ;
46
34
import java .util .UUID ;
47
35
48
- import static org .openqa .selenium .remote .http .Contents .reader ;
49
36
import static org .openqa .selenium .remote .http .Route .combine ;
50
37
import static org .openqa .selenium .remote .http .Route .delete ;
51
38
import static org .openqa .selenium .remote .http .Route .get ;
52
39
import static org .openqa .selenium .remote .http .Route .post ;
53
- import static org .openqa .selenium .remote .tracing .Tags .EXCEPTION ;
54
40
55
41
public abstract class NewSessionQueuer implements HasReadyState , Routable {
56
42
@@ -64,7 +50,6 @@ protected NewSessionQueuer(Tracer tracer, Secret registrationSecret) {
64
50
RequiresSecretFilter requiresSecret = new RequiresSecretFilter (registrationSecret );
65
51
66
52
routes = combine (
67
-
68
53
post ("/session" )
69
54
.to (() -> this ::addToQueue ),
70
55
post ("/se/grid/newsessionqueuer/session" )
@@ -86,38 +71,6 @@ private RequestId requestIdFrom(Map<String, String> params) {
86
71
return new RequestId (UUID .fromString (params .get ("requestId" )));
87
72
}
88
73
89
- public void validateSessionRequest (HttpRequest request ) {
90
- try (Span span = tracer .getCurrentContext ().createSpan ("newsession_queuer.validate" )) {
91
- Map <String , EventAttributeValue > attributeMap = new HashMap <>();
92
- try (
93
- Reader reader = reader (request );
94
- NewSessionPayload payload = NewSessionPayload .create (reader )) {
95
- Objects .requireNonNull (payload , "Requests to process must be set." );
96
- attributeMap .put ("request.payload" , EventAttribute .setValue (payload .toString ()));
97
-
98
- Iterator <Capabilities > iterator = payload .stream ().iterator ();
99
- if (!iterator .hasNext ()) {
100
- SessionNotCreatedException exception =
101
- new SessionNotCreatedException ("No capabilities found" );
102
- EXCEPTION .accept (attributeMap , exception );
103
- attributeMap .put (
104
- AttributeKey .EXCEPTION_MESSAGE .getKey (), EventAttribute .setValue (exception .getMessage ()));
105
- span .addEvent (AttributeKey .EXCEPTION_EVENT .getKey (), attributeMap );
106
- throw exception ;
107
- }
108
- } catch (IOException e ) {
109
- SessionNotCreatedException exception = new SessionNotCreatedException (e .getMessage (), e );
110
- EXCEPTION .accept (attributeMap , exception );
111
- String errorMessage = "IOException while reading the request payload. " +
112
- exception .getMessage ();
113
- attributeMap .put (
114
- AttributeKey .EXCEPTION_MESSAGE .getKey (), EventAttribute .setValue (errorMessage ));
115
- span .addEvent (AttributeKey .EXCEPTION_EVENT .getKey (), attributeMap );
116
- throw exception ;
117
- }
118
- }
119
- }
120
-
121
74
public abstract HttpResponse addToQueue (HttpRequest request );
122
75
123
76
public abstract boolean retryAddToQueue (HttpRequest request , RequestId reqId );
0 commit comments