Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible mutation of self.routes during routeURL if route is added at the same time #81

Closed
bcriscuolo opened this issue Nov 7, 2016 · 2 comments

Comments

@bcriscuolo
Copy link

This one gets me from time to time, as the process of routing a URL ends up adding a route elsewhere, and the outcome is always "fun".

routeURL:withParameters:executeRouteBlock: uses fast enumeration of self.routes to match for a valid route handler.

However, while this enumeration is happening, register or remove methods may be called which will modify the mutable array of self.routes.

I suggest that in routeURL:withParameters:executeRouteBlock: you first copy self.routes to an immutable NSArray and use that to enumerate the routes contained.

You'd be protected against the dreaded Collection <__NSArrayM: 0x17405dc70> was mutated while being enumerated. error.

Thank you. Keep up the good work,

Brian M. Criscuolo
warmwinds software

@bcriscuolo
Copy link
Author

There are other places where self.routes is enumerated in the code; any place this is happening is ripe for having a local copy of the array to be used for the enumeration.

@joeldev
Copy link
Owner

joeldev commented Nov 8, 2016

Good find! I can't believe I missed that.

@joeldev joeldev closed this as completed in 932c6c3 Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants