Open nicolabeghin opened 8 years ago
It looks like your object is not getting put into cache, and because of that RoboSpice keeps executing a request every time because there's nothing in the cache. Must be some issue with Jackson serializing this 'ReportTemplateWrapper' object and fails to do so. RoboSpice writes detailed logs. Please explore a log in AndroidStudio to track down an error. And/or post a log here if needed. Log must begin from exact moment after this.getSpiceManager().execute(request, request.createCacheKey(), DurationInMillis.ONE_DAY, new ReportTemplatesRequestRequestListener(this))
is called.
hi @mykolaj you're absolutely right. I forgot to update the issue as it took me a day to figure out the source of the problem.
I had to dig deeper to find out why the same exact SpiceRequest
failed on Samsung devices while it didn't on other devices, and narrowed it down to a class like the one below
@JsonIgnoreProperties(ignoreUnknown = true)
@com.orm.dsl.Table(name = "report_field_instances")
public class ReportFieldInstance extends SugarRecord {
private String title;
@JsonProperty(value = "ReportFieldType")
private ReportFieldType reportFieldType;
@JsonProperty(value = "report_template_id")
private int reportTemplateId;
@JsonProperty(value = "report_field_type_id")
private int reportFieldTypeId;
private boolean required;
@com.orm.dsl.Column(name = "orderby")
private int order;
@Ignore
@JsonIgnore
private View view;
}
Robospice invokes the Jackson method ObjectMapper.canSerialize
that prevents the parsing from being carried out at all if any non-serializable field is found in the given object. In my case, failing silently on Samsung devices (and only on Samsung devices, ie on my Moto X it was carried out successfully).
In case it can help anyone: just adding the @JsonIgnore
annotation fixed this (nightmare-ish) bug.
@JsonIgnore
private View view;
Hi I think I narrowed down a nasty bug. I hope I'm wrong, but I made some pretty extensive testing in order to get down to this.
I'm using
Jackson2SpringAndroidSpiceService
which in turns useJackson2ObjectPersisterFactory
:Having a pretty simple situation like this
when i use
the
DurationInMillis.ONE_DAY
caching is not respected (I checked Apache's access logs and requests are logged each time).While if I change the definition to
to make sure the
reportFieldInstances
List
is not populed by Jackson unmarshaller, caching-time is respected (please note the "ReportFieldInstance" changed in "ReportFieldInstance222");So this is my assumption: if a sub-type of the returned object is a populated List, Robospice automatically skips caching. I hope I'm wrong but changing that single property made all the difference, so something weird's happening in the background.
Library versions: