From 9de1c1fde1abe12d5cf795fc67ed233018b0b40e Mon Sep 17 00:00:00 2001 From: Brett Hoerner Date: Wed, 19 Sep 2018 10:16:00 -0500 Subject: [PATCH] Drop events when the server returns an HTTP 429. --- CHANGES | 1 + .../main/java/io/sentry/connection/BufferedConnection.java | 4 ++-- .../java/io/sentry/connection/BufferedConnectionTest.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 9b09ab9da75..af2914afe7f 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ Version 1.7.10 -------------- - Android Plugin: Look for properties file directly under flavor directory. (thanks biggestT) +- Drop events when the server returns an HTTP 429. Version 1.7.9 ------------- diff --git a/sentry/src/main/java/io/sentry/connection/BufferedConnection.java b/sentry/src/main/java/io/sentry/connection/BufferedConnection.java index d904c36b0fe..0cd19a41a79 100644 --- a/sentry/src/main/java/io/sentry/connection/BufferedConnection.java +++ b/sentry/src/main/java/io/sentry/connection/BufferedConnection.java @@ -107,10 +107,10 @@ public void send(Event event) { boolean notSerializable = e.getCause() instanceof NotSerializableException; Integer responseCode = e.getResponseCode(); - if (notSerializable || (responseCode != null && responseCode != HttpConnection.HTTP_TOO_MANY_REQUESTS)) { + if (notSerializable || (responseCode != null)) { // don't retry events (discard from the buffer) if: // 1. they aren't serializable - // 2. the connection is up (valid response code was returned) and it's not an HTTP 429 + // 2. the connection is up (valid response code was returned) buffer.discard(event); } diff --git a/sentry/src/test/java/io/sentry/connection/BufferedConnectionTest.java b/sentry/src/test/java/io/sentry/connection/BufferedConnectionTest.java index 46d8a6fa08f..e0cc4e27f0f 100644 --- a/sentry/src/test/java/io/sentry/connection/BufferedConnectionTest.java +++ b/sentry/src/test/java/io/sentry/connection/BufferedConnectionTest.java @@ -156,7 +156,7 @@ public void test500NotBuffered() throws Exception { } @Test - public void test429IsBuffered() throws Exception { + public void test429IsNotBuffered() throws Exception { Event event = new EventBuilder().build(); connectionException = new ConnectionException("429", new IOException(), null, HttpConnection.HTTP_TOO_MANY_REQUESTS); try { @@ -164,7 +164,7 @@ public void test429IsBuffered() throws Exception { } catch (Exception e) { } - assertThat(bufferedEvents.size(), equalTo(1)); + assertThat(bufferedEvents.size(), equalTo(0)); } @Test