-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[response].flatten causes infinite loop #419
Copy link
Copy link
Closed
Milestone
Description
Rack::Response#finishis aliased withto_ary[1]Rack::Response#finishreturns an array includingselfwhen the response code is anything other than 204, 205, 304 [2]
The result is an infinite loop if the result of app.call(env) (assigned to response in Rails' testing framework) is included in an array that is flattened. The reason is that Array#flatten invokes to_ary on each element that responds to to_ary, then does the same to the contents of the result of to_ary, and so on.
Because self is in the array returned by to_ary, it gets to_ary invoked and returns the same array, including self, which then gets to_ary invoked on it, which returns the same array, including self, and so on.
[1]
Line 83 in ab67e70
| alias to_ary finish # For implicit-splat on Ruby 1.9.2 |
[2]
Line 79 in ab67e70
| [status.to_i, header, self] |
Reactions are currently unavailable