[TIMOB-16201] ACS: cocoafish crashes when you execute the requests with multi-thread
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2017-07-26T04:15:56.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | kazuaki konno |
Assignee | Eric Merriman |
Created | 2013-11-11T11:18:53.000+0000 |
Updated | 2017-07-26T04:15:56.000+0000 |
Description
cocoafish crashes when you execute the requests with multi-thread.
According to Apple's documents, it says below.
"Note: NSDateFormatter is not thread safe, so you must not mutate a given date formatter simultaneously from multiple threads."
cocoa fish's class is instantiate as following;
NSOperation > ASIHTTPRequest > ASIFormDataRequest > CCRequest
It means cocoa fish execute in multi-thread even though it should not be. So it happens crash.
[CCObject.m Line:42]
NSString *dateString = [jsonResponse objectForKey:CC_JSON_CREATED_AT];
if (dateString) {
self.createdAt = [[[Cocoafish defaultCocoafish] jsonDateFormatter] dateFromString:dateString];
}
dateString = [jsonResponse objectForKey:CC_JSON_UPDATED_AT];
if (dateString) {
self.updatedAt = [[[Cocoafish defaultCocoafish] jsonDateFormatter] dateFromString:dateString];
}
We struggle to solve this problem. And we reached the following solution.
NSDateFormatter *dateFormatter = [[[Cocoafish defaultCocoafish] jsonDateFormatter] copy];
NSString *dateString = [jsonResponse objectForKey:CC_JSON_CREATED_AT];
if (dateString) {
self.createdAt = [dateFormatter dateFromString:dateString];
}
dateString = [jsonResponse objectForKey:CC_JSON_UPDATED_AT];
if (dateString) {
self.updatedAt = [dateFormatter dateFromString:dateString];
}
[dateFormatter release];
I hope cocoafish will be maintained and updated.
Hello Kazuaki, can you please provide a test case for this? If you have the one that generated the logs, will be awesome. Best, Mauro
Attached is test project. It will crash with iPhone4 iOS5.1.1 using Xcode5. Please set your AppKey to the project. Here is the test project. https://skydrive.live.com/redir?resid=D37D16E469EB75CA%215954
Hi Mauro, Shak, I hope it will help. kaz
Hello Kaz, thanks for the testcase, I will reviewing this one and moving it shortly. Best, Mauro
Closing due to inactivity. If this issue still exists, please raise a new ticket.