Skip to content

Commit bd1ad49

Browse files
committed
Tag and exception
1 parent 15c5c90 commit bd1ad49

File tree

1 file changed

+8
-2
lines changed
  • transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/scheduling/jobscheduling

1 file changed

+8
-2
lines changed

transport/transport-runtime/src/main/java/com/google/android/datatransport/runtime/scheduling/jobscheduling/WorkManagerScheduler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public WorkManagerScheduler(
5555
this.config = config;
5656
}
5757

58+
private String getTag(int jobId) {
59+
return "transport-" + jobId;
60+
}
61+
5862
@Override
5963
public void schedule(TransportContext transportContext, int attemptNumber) {
6064
schedule(transportContext, attemptNumber, false);
@@ -67,7 +71,7 @@ public void schedule(TransportContext transportContext, int attemptNumber, boole
6771
int jobId = WorkScheduler.getJobId(context, transportContext);
6872
if (!force) {
6973
try {
70-
for (WorkInfo info : manager.getWorkInfosByTag("transport-" + jobId).get()) {
74+
for (WorkInfo info : manager.getWorkInfosByTag(this.getTag(jobId)).get()) {
7175
if (!info.getState().isFinished()) {
7276
Logging.d(
7377
LOG_TAG,
@@ -77,6 +81,8 @@ public void schedule(TransportContext transportContext, int attemptNumber, boole
7781
}
7882
}
7983
} catch (Exception e) {
84+
// Various Future failure states that shouldn't be possible
85+
throw new RuntimeException(e);
8086
}
8187
}
8288

@@ -107,7 +113,7 @@ public void schedule(TransportContext transportContext, int attemptNumber, boole
107113
new OneTimeWorkRequest.Builder(WorkManagerSchedulerWorker.class)
108114
.setInitialDelay(scheduleDelay, TimeUnit.MILLISECONDS)
109115
.setInputData(dataBuilder.build())
110-
.addTag("transport-" + jobId)
116+
.addTag(this.getTag(jobId))
111117
.build();
112118
manager.enqueue(request);
113119
}

0 commit comments

Comments
 (0)