@@ -106,14 +106,14 @@ struct HTTP1ConnectionStateMachine{
106106return . wait
107107
108108case . modifying:
109- preconditionFailure ( " Invalid state: \( self . state) " )
109+ fatalError ( " Invalid state: \( self . state) " )
110110}
111111}
112112
113113mutating func channelInactive( ) -> Action {
114114switch self . state {
115115case . 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 " )
117117
118118case . inRequest( var requestStateMachine, close: _) :
119119return self . avoidingStateMachineCoW { state -> Action in
@@ -130,7 +130,7 @@ struct HTTP1ConnectionStateMachine{
130130return . wait
131131
132132case . modifying:
133- preconditionFailure ( " Invalid state: \( self . state) " )
133+ fatalError ( " Invalid state: \( self . state) " )
134134}
135135}
136136
@@ -155,7 +155,7 @@ struct HTTP1ConnectionStateMachine{
155155return . fireChannelError( error, closeConnection: false )
156156
157157case . modifying:
158- preconditionFailure ( " Invalid state: \( self . state) " )
158+ fatalError ( " Invalid state: \( self . state) " )
159159}
160160}
161161
@@ -173,7 +173,7 @@ struct HTTP1ConnectionStateMachine{
173173}
174174
175175case . modifying:
176- preconditionFailure ( " Invalid state: \( self . state) " )
176+ fatalError ( " Invalid state: \( self . state) " )
177177}
178178}
179179
@@ -182,15 +182,15 @@ struct HTTP1ConnectionStateMachine{
182182 metadata: RequestFramingMetadata
183183) -> Action {
184184switch self . state {
185- case . initialized, . closing , . inRequest:
185+ case . initialized, . inRequest:
186186 // These states are unreachable as the connection pool state machine has put the
187187 // connection into these states. In other words the connection pool state machine must
188188 // be aware about these states before the connection itself. For this reason the
189189 // connection pool state machine must not send a new request to the connection, if the
190190 // connection is `.initialized`, `.closing` or `.inRequest`
191- preconditionFailure ( " Invalid state: \( self . state) " )
191+ fatalError ( " Invalid state: \( self . state) " )
192192
193- case . closed:
193+ case . closing , . closed:
194194 // The remote may have closed the connection and the connection pool state machine
195195 // was not updated yet because of a race condition. New request vs. marking connection
196196 // as closed.
@@ -208,13 +208,13 @@ struct HTTP1ConnectionStateMachine{
208208return self . state. modify ( with: action)
209209
210210case . modifying:
211- preconditionFailure ( " Invalid state: \( self . state) " )
211+ fatalError ( " Invalid state: \( self . state) " )
212212}
213213}
214214
215215mutating func requestStreamPartReceived( _ part: IOData , promise: EventLoopPromise < Void > ? ) -> Action {
216216guard case . inRequest( var requestStateMachine, let close) = self . state else {
217- preconditionFailure ( " Invalid state: \( self . state) " )
217+ fatalError ( " Invalid state: \( self . state) " )
218218}
219219
220220return self . avoidingStateMachineCoW { state -> Action in
@@ -226,7 +226,7 @@ struct HTTP1ConnectionStateMachine{
226226
227227mutating func requestStreamFinished( promise: EventLoopPromise < Void > ? ) -> Action {
228228guard case . inRequest( var requestStateMachine, let close) = self . state else {
229- preconditionFailure ( " Invalid state: \( self . state) " )
229+ fatalError ( " Invalid state: \( self . state) " )
230230}
231231
232232return self . avoidingStateMachineCoW { state -> Action in
@@ -239,7 +239,7 @@ struct HTTP1ConnectionStateMachine{
239239mutating func requestCancelled( closeConnection: Bool ) -> Action {
240240switch self . state {
241241case . 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) " )
243243
244244case . idle:
245245if closeConnection {
@@ -260,7 +260,7 @@ struct HTTP1ConnectionStateMachine{
260260return . wait
261261
262262case . modifying:
263- preconditionFailure ( " Invalid state: \( self . state) " )
263+ fatalError ( " Invalid state: \( self . state) " )
264264}
265265}
266266
@@ -269,7 +269,7 @@ struct HTTP1ConnectionStateMachine{
269269mutating func read( ) -> Action {
270270switch self . state {
271271case . 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 " )
273273case . idle:
274274return . read
275275case . inRequest( var requestStateMachine, let close) :
@@ -284,14 +284,14 @@ struct HTTP1ConnectionStateMachine{
284284return . read
285285
286286case . modifying:
287- preconditionFailure ( " Invalid state: \( self . state) " )
287+ fatalError ( " Invalid state: \( self . state) " )
288288}
289289}
290290
291291mutating func channelRead( _ part: HTTPClientResponsePart ) -> Action {
292292switch self . state {
293293case . initialized, . idle:
294- preconditionFailure ( " Invalid state: \( self . state) " )
294+ fatalError ( " Invalid state: \( self . state) " )
295295
296296case . inRequest( var requestStateMachine, var close) :
297297return self . avoidingStateMachineCoW { state -> Action in
@@ -310,7 +310,7 @@ struct HTTP1ConnectionStateMachine{
310310return . wait
311311
312312case . modifying:
313- preconditionFailure ( " Invalid state: \( self . state) " )
313+ fatalError ( " Invalid state: \( self . state) " )
314314}
315315}
316316
@@ -327,13 +327,13 @@ struct HTTP1ConnectionStateMachine{
327327}
328328
329329case . modifying:
330- preconditionFailure ( " Invalid state: \( self . state) " )
330+ fatalError ( " Invalid state: \( self . state) " )
331331}
332332}
333333
334334mutating func demandMoreResponseBodyParts( ) -> Action {
335335guard case . inRequest( var requestStateMachine, let close) = self . state else {
336- preconditionFailure ( " Invalid state: \( self . state) " )
336+ fatalError ( " Invalid state: \( self . state) " )
337337}
338338
339339return self . avoidingStateMachineCoW { state -> Action in
@@ -345,7 +345,7 @@ struct HTTP1ConnectionStateMachine{
345345
346346mutating func idleReadTimeoutTriggered( ) -> Action {
347347guard case . inRequest( var requestStateMachine, let close) = self . state else {
348- preconditionFailure ( " Invalid state: \( self . state) " )
348+ fatalError ( " Invalid state: \( self . state) " )
349349}
350350
351351return self . avoidingStateMachineCoW { state -> Action in
@@ -423,7 +423,7 @@ extension HTTP1ConnectionStateMachine.State{
423423return . forwardResponseBodyParts( parts)
424424case . succeedRequest( let finalAction, let finalParts) :
425425guard case . inRequest( _, close: let close) = self else {
426- preconditionFailure ( " Invalid state: \( self ) " )
426+ fatalError ( " Invalid state: \( self ) " )
427427}
428428
429429let newFinalAction : HTTP1ConnectionStateMachine . Action . FinalSuccessfulStreamAction
@@ -443,9 +443,9 @@ extension HTTP1ConnectionStateMachine.State{
443443case . failRequest( let error, let finalAction) :
444444switch self {
445445case . initialized:
446- preconditionFailure ( " Invalid state: \( self ) " )
446+ fatalError ( " Invalid state: \( self ) " )
447447case . 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 " )
449449case . inRequest( _, close: let close) :
450450if case . close( let promise) = finalAction {
451451self = . closing
@@ -465,7 +465,7 @@ extension HTTP1ConnectionStateMachine.State{
465465return . failRequest( error, . none)
466466
467467case . modifying:
468- preconditionFailure ( " Invalid state: \( self ) " )
468+ fatalError ( " Invalid state: \( self ) " )
469469}
470470
471471case . read:
@@ -497,7 +497,7 @@ extension HTTP1ConnectionStateMachine: CustomStringConvertible{
497497case . closed:
498498return " .closed "
499499case . modifying:
500- preconditionFailure ( " Invalid state: \( self . state) " )
500+ fatalError ( " Invalid state: \( self . state) " )
501501}
502502}
503503}
0 commit comments