robospice
robospice copied to clipboard
Request with PRIORITY_HIGH is cancelled when SpiceManager.cancel is called before it
I am doing following:
spiceManager.cancel(Results.class, "CacheKey");
MyRequest request = new MyRequest();
request.setPriority(SpiceRequest.PRIORITY_HIGH);
spiceManager.execute(request, "CacheKey", DurationInMillis.ALWAYS_EXPIRED, new MyListener());
In such case MyListener gets onFailure with cancelled description.
As I looked at source it is because spiceManager.cancel() is creating SpiceRequest with PRIORITY_NORMAL. Those two request are rearranged and in such case MyRequest is first and Cancel Request is second. That is causing to MyRequest cancelled.
I am not sure this is really a bug but more a side effect of how things work. What result would you expect ?
@stephanenicolas I would expect that calling cancel before calling execute would not cancel that request. Similar thing is happening with adding request then listener for that request (I need it in state machine), adding listener also cause to create request. Then it is possible that listener request will be called before our request and in such case listener is not attached and we never get result..