RestKit/RestKit — Issue #500: RKRequestQueue: mutating Array wile enumerating it
Author: haemi
Created: 2012-01-11 13:03:27+00:00
State: open

in RKRequestQueue, sometimes the NSMutableArray of RequestQueues is updated while it's enumerated:

+ (BOOL)requestQueueExistsWithName:(NSString*)name {
if (RKRequestQueueInstances) {
for (NSValue* value in RKRequestQueueInstances) {
RKRequestQueue* queue = (RKRequestQueue*) [value nonretainedObjectValue];
if ([queue.name isEqualToString:name]) {
return YES;
}
}
}

return NO;
}

Shouldn't the RKRequestQueueInstances be copied before enumerating?

+ (BOOL)requestQueueExistsWithName:(NSString*)name {
if (RKRequestQueueInstances) {
NSArray *requestQueueInstances = [RKRequestQueueInstances copy];
for (NSValue* value in requestQueueInstances) {
RKRequestQueue* queue = (RKRequestQueue*) [value nonretainedObjectValue];
if ([queue.name isEqualToString:name]) {
return YES;
}
}
}

return NO;
}

Same for + (id)requestQueueWithName:(NSString *)name.

This can happen whenever some RequestQueue is finished while in another thread a new one is created.