@@ -106,14 +106,14 @@ struct HTTP1ConnectionStateMachine {
106
106
return . wait
107
107
108
108
case . modifying:
109
- preconditionFailure ( " Invalid state: \( self . state) " )
109
+ fatalError ( " Invalid state: \( self . state) " )
110
110
}
111
111
}
112
112
113
113
mutating func channelInactive( ) -> Action {
114
114
switch self . state {
115
115
case . initialized:
116
- preconditionFailure ( " A channel that isn't active, must not become inactive " )
116
+ fatalError ( " A channel that isn't active, must not become inactive " )
117
117
118
118
case . inRequest( var requestStateMachine, close: _) :
119
119
return self . avoidingStateMachineCoW { state -> Action in
@@ -130,7 +130,7 @@ struct HTTP1ConnectionStateMachine {
130
130
return . wait
131
131
132
132
case . modifying:
133
- preconditionFailure ( " Invalid state: \( self . state) " )
133
+ fatalError ( " Invalid state: \( self . state) " )
134
134
}
135
135
}
136
136
@@ -155,7 +155,7 @@ struct HTTP1ConnectionStateMachine {
155
155
return . fireChannelError( error, closeConnection: false )
156
156
157
157
case . modifying:
158
- preconditionFailure ( " Invalid state: \( self . state) " )
158
+ fatalError ( " Invalid state: \( self . state) " )
159
159
}
160
160
}
161
161
@@ -173,7 +173,7 @@ struct HTTP1ConnectionStateMachine {
173
173
}
174
174
175
175
case . modifying:
176
- preconditionFailure ( " Invalid state: \( self . state) " )
176
+ fatalError ( " Invalid state: \( self . state) " )
177
177
}
178
178
}
179
179
@@ -182,15 +182,15 @@ struct HTTP1ConnectionStateMachine {
182
182
metadata: RequestFramingMetadata
183
183
) -> Action {
184
184
switch self . state {
185
- case . initialized, . closing , . inRequest:
185
+ case . initialized, . inRequest:
186
186
// These states are unreachable as the connection pool state machine has put the
187
187
// connection into these states. In other words the connection pool state machine must
188
188
// be aware about these states before the connection itself. For this reason the
189
189
// connection pool state machine must not send a new request to the connection, if the
190
190
// connection is `.initialized`, `.closing` or `.inRequest`
191
- preconditionFailure ( " Invalid state: \( self . state) " )
191
+ fatalError ( " Invalid state: \( self . state) " )
192
192
193
- case . closed:
193
+ case . closing , . closed:
194
194
// The remote may have closed the connection and the connection pool state machine
195
195
// was not updated yet because of a race condition. New request vs. marking connection
196
196
// as closed.
@@ -208,13 +208,13 @@ struct HTTP1ConnectionStateMachine {
208
208
return self . state. modify ( with: action)
209
209
210
210
case . modifying:
211
- preconditionFailure ( " Invalid state: \( self . state) " )
211
+ fatalError ( " Invalid state: \( self . state) " )
212
212
}
213
213
}
214
214
215
215
mutating func requestStreamPartReceived( _ part: IOData , promise: EventLoopPromise < Void > ? ) -> Action {
216
216
guard case . inRequest( var requestStateMachine, let close) = self . state else {
217
- preconditionFailure ( " Invalid state: \( self . state) " )
217
+ fatalError ( " Invalid state: \( self . state) " )
218
218
}
219
219
220
220
return self . avoidingStateMachineCoW { state -> Action in
@@ -226,7 +226,7 @@ struct HTTP1ConnectionStateMachine {
226
226
227
227
mutating func requestStreamFinished( promise: EventLoopPromise < Void > ? ) -> Action {
228
228
guard case . inRequest( var requestStateMachine, let close) = self . state else {
229
- preconditionFailure ( " Invalid state: \( self . state) " )
229
+ fatalError ( " Invalid state: \( self . state) " )
230
230
}
231
231
232
232
return self . avoidingStateMachineCoW { state -> Action in
@@ -239,7 +239,7 @@ struct HTTP1ConnectionStateMachine {
239
239
mutating func requestCancelled( closeConnection: Bool ) -> Action {
240
240
switch self . state {
241
241
case . initialized:
242
- preconditionFailure ( " This event must only happen, if the connection is leased. During startup this is impossible. Invalid state: \( self . state) " )
242
+ fatalError ( " This event must only happen, if the connection is leased. During startup this is impossible. Invalid state: \( self . state) " )
243
243
244
244
case . idle:
245
245
if closeConnection {
@@ -260,7 +260,7 @@ struct HTTP1ConnectionStateMachine {
260
260
return . wait
261
261
262
262
case . modifying:
263
- preconditionFailure ( " Invalid state: \( self . state) " )
263
+ fatalError ( " Invalid state: \( self . state) " )
264
264
}
265
265
}
266
266
@@ -269,7 +269,7 @@ struct HTTP1ConnectionStateMachine {
269
269
mutating func read( ) -> Action {
270
270
switch self . state {
271
271
case . initialized:
272
- preconditionFailure ( " Why should we read something, if we are not connected yet " )
272
+ fatalError ( " Why should we read something, if we are not connected yet " )
273
273
case . idle:
274
274
return . read
275
275
case . inRequest( var requestStateMachine, let close) :
@@ -284,14 +284,14 @@ struct HTTP1ConnectionStateMachine {
284
284
return . read
285
285
286
286
case . modifying:
287
- preconditionFailure ( " Invalid state: \( self . state) " )
287
+ fatalError ( " Invalid state: \( self . state) " )
288
288
}
289
289
}
290
290
291
291
mutating func channelRead( _ part: HTTPClientResponsePart ) -> Action {
292
292
switch self . state {
293
293
case . initialized, . idle:
294
- preconditionFailure ( " Invalid state: \( self . state) " )
294
+ fatalError ( " Invalid state: \( self . state) " )
295
295
296
296
case . inRequest( var requestStateMachine, var close) :
297
297
return self . avoidingStateMachineCoW { state -> Action in
@@ -310,7 +310,7 @@ struct HTTP1ConnectionStateMachine {
310
310
return . wait
311
311
312
312
case . modifying:
313
- preconditionFailure ( " Invalid state: \( self . state) " )
313
+ fatalError ( " Invalid state: \( self . state) " )
314
314
}
315
315
}
316
316
@@ -327,13 +327,13 @@ struct HTTP1ConnectionStateMachine {
327
327
}
328
328
329
329
case . modifying:
330
- preconditionFailure ( " Invalid state: \( self . state) " )
330
+ fatalError ( " Invalid state: \( self . state) " )
331
331
}
332
332
}
333
333
334
334
mutating func demandMoreResponseBodyParts( ) -> Action {
335
335
guard case . inRequest( var requestStateMachine, let close) = self . state else {
336
- preconditionFailure ( " Invalid state: \( self . state) " )
336
+ fatalError ( " Invalid state: \( self . state) " )
337
337
}
338
338
339
339
return self . avoidingStateMachineCoW { state -> Action in
@@ -345,7 +345,7 @@ struct HTTP1ConnectionStateMachine {
345
345
346
346
mutating func idleReadTimeoutTriggered( ) -> Action {
347
347
guard case . inRequest( var requestStateMachine, let close) = self . state else {
348
- preconditionFailure ( " Invalid state: \( self . state) " )
348
+ fatalError ( " Invalid state: \( self . state) " )
349
349
}
350
350
351
351
return self . avoidingStateMachineCoW { state -> Action in
@@ -423,7 +423,7 @@ extension HTTP1ConnectionStateMachine.State {
423
423
return . forwardResponseBodyParts( parts)
424
424
case . succeedRequest( let finalAction, let finalParts) :
425
425
guard case . inRequest( _, close: let close) = self else {
426
- preconditionFailure ( " Invalid state: \( self ) " )
426
+ fatalError ( " Invalid state: \( self ) " )
427
427
}
428
428
429
429
let newFinalAction : HTTP1ConnectionStateMachine . Action . FinalSuccessfulStreamAction
@@ -443,9 +443,9 @@ extension HTTP1ConnectionStateMachine.State {
443
443
case . failRequest( let error, let finalAction) :
444
444
switch self {
445
445
case . initialized:
446
- preconditionFailure ( " Invalid state: \( self ) " )
446
+ fatalError ( " Invalid state: \( self ) " )
447
447
case . idle:
448
- preconditionFailure ( " How can we fail a task, if we are idle " )
448
+ fatalError ( " How can we fail a task, if we are idle " )
449
449
case . inRequest( _, close: let close) :
450
450
if case . close( let promise) = finalAction {
451
451
self = . closing
@@ -465,7 +465,7 @@ extension HTTP1ConnectionStateMachine.State {
465
465
return . failRequest( error, . none)
466
466
467
467
case . modifying:
468
- preconditionFailure ( " Invalid state: \( self ) " )
468
+ fatalError ( " Invalid state: \( self ) " )
469
469
}
470
470
471
471
case . read:
@@ -497,7 +497,7 @@ extension HTTP1ConnectionStateMachine: CustomStringConvertible {
497
497
case . closed:
498
498
return " .closed "
499
499
case . modifying:
500
- preconditionFailure ( " Invalid state: \( self . state) " )
500
+ fatalError ( " Invalid state: \( self . state) " )
501
501
}
502
502
}
503
503
}
0 commit comments