Skip to content

Commit b5286b0

Browse files
authored
Drop events when the server returns an HTTP 429. (#613)
1 parent 20e3e0b commit b5286b0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Version 1.7.10
22
--------------
33

44
- Android Plugin: Look for properties file directly under flavor directory. (thanks biggestT)
5+
- Drop events when the server returns an HTTP 429.
56

67
Version 1.7.9
78
-------------

sentry/src/main/java/io/sentry/connection/BufferedConnection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ public void send(Event event) {
107107
boolean notSerializable = e.getCause() instanceof NotSerializableException;
108108

109109
Integer responseCode = e.getResponseCode();
110-
if (notSerializable || (responseCode != null && responseCode != HttpConnection.HTTP_TOO_MANY_REQUESTS)) {
110+
if (notSerializable || (responseCode != null)) {
111111
// don't retry events (discard from the buffer) if:
112112
// 1. they aren't serializable
113-
// 2. the connection is up (valid response code was returned) and it's not an HTTP 429
113+
// 2. the connection is up (valid response code was returned)
114114
buffer.discard(event);
115115
}
116116

sentry/src/test/java/io/sentry/connection/BufferedConnectionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ public void test500NotBuffered() throws Exception {
156156
}
157157

158158
@Test
159-
public void test429IsBuffered() throws Exception {
159+
public void test429IsNotBuffered() throws Exception {
160160
Event event = new EventBuilder().build();
161161
connectionException = new ConnectionException("429", new IOException(), null, HttpConnection.HTTP_TOO_MANY_REQUESTS);
162162
try {
163163
bufferedConnection.send(event);
164164
} catch (Exception e) {
165165

166166
}
167-
assertThat(bufferedEvents.size(), equalTo(1));
167+
assertThat(bufferedEvents.size(), equalTo(0));
168168
}
169169

170170
@Test

0 commit comments

Comments
 (0)