android-priority-jobqueue
android-priority-jobqueue copied to clipboard
when the job set requireNetwork and persist ,onRun will execute twice
1.open the network 2.post the job (the job will onRun but not done) 3.close the network (when execute uploadImage method will exception) 4.open the network 5.the onRun method will execute twice
version 2.0.1
the simple code ` public class FeedbackTestJob extends Job {
public FeedbackTestJob(String con, String contact, List<String> images) {
super(new Params(Priority.LOW).requireNetwork().persist());
LogUtils.d("onCreate" + getId());
}
@Override
public void onAdded() {
LogUtils.d("onAdded" + getId());
}
@Override
public void onRun() throws Throwable {
LogUtils.d("onRun" + getId());
Thread.sleep(5000);
uploadImage();
LogUtils.d("end");
}
/**
*/
private void uploadImage() {
//uploadImage code
}
@Override
protected void onCancel(int cancelReason, @Nullable Throwable throwable) {
}
@Override
protected RetryConstraint shouldReRunOnThrowable(@NonNull Throwable throwable, int runCount, int maxRunCount) {
LogUtils.d("error");
if (runCount == 4)
return RetryConstraint.CANCEL;
return RetryConstraint.RETRY;
}
}`
` public void initJobManager(Context context) { Configuration.Builder builder = new Configuration.Builder(context) .customLogger(new CustomLogger() { private static final String TAG = "shenluntikuapp job";
@Override
public boolean isDebugEnabled() {
return true;
}
@Override
public void d(String text, Object... args) {
Log.d(TAG, String.format(text, args));
}
@Override
public void e(Throwable t, String text, Object... args) {
Log.e(TAG, String.format(text, args), t);
}
@Override
public void e(String text, Object... args) {
Log.e(TAG, String.format(text, args));
}
@Override
public void v(String text, Object... args) {
}
})
.minConsumerCount(1)
.maxConsumerCount(3)
.loadFactor(3)//
.consumerKeepAlive(120);
jobManager = new JobManager(builder.build());
}`
@shingohu did you find a solution?
@wandering7man
do you have this problem too?
version 1.3.5 is not problem
@shingohu I can't reproduce it by myself, but our users sometimes can, very flaky bug.
@wandering7man 1.open the network 2.post the job (the job will onRun but not done) 3.close the network (when execute uploadImage method will exception) 4.open the network 5.the onRun method will execute twice like this can't reproduce?
@shingohu nope :(