Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
/ sentry-android Public archive

Honor RetryAfter #236

Merged
merged 9 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed comments
marandaneto committed Jan 16, 2020
commit 3171d6742b42bdc5ce9f5465a78280f63f15a356
Original file line number Diff line number Diff line change
@@ -93,7 +93,6 @@ public void send(SentryEvent event, @Nullable Object hint) throws IOException {
currentEventCache = NoOpEventCache.getInstance();
}
executor.submit(new EventSender(event, hint, currentEventCache));
// future.cancel(true); if I hold a reference of the future here, I can only cancel it anyway
}

@Override
@@ -175,12 +174,7 @@ private TransportResult flush() {
.log(SentryLevel.DEBUG, "Disk flush event fired: %s", event.getEventId());
}

// might be able to hacky this if I check the last result, at least is gonna store, but wont
// try again after X seconds, only after restart
// or maybe even using a hint
if (transportGate
.isSendingAllowed()) { // maybe a pauseLock = new ReentrantLock(); here too, but we still
// need to calculate the time
if (transportGate.isSendingAllowed()) {
try {
result = transport.send(event);
if (result.isSuccess()) {
Original file line number Diff line number Diff line change
@@ -171,23 +171,10 @@ protected void afterExecute(Runnable r, Throwable t) {
}

if (responseCode == HTTP_TOO_MANY_REQUESTS) {
// if I delay or await this thread to finish respecting delayMillis, next ones might not
// have the chance to cache the event
// eg
// https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html
// using a ReentrantLock pauseLock

// List<Runnable> runnables = shutdownNow();
// it should be possible to reschedule again with the delay, but again, we delay the
// caching of events
// shutdownNow();
getQueue().clear();

scheduleRetryAfterDelay(delayMillis);
}
// schedule(new NextAttempt(attempt, ar.suppliedAction), delayMillis,
// TimeUnit.MILLISECONDS);
// }
}
} finally {
currentlyRunning.decrementAndGet();