@@ -139,7 +139,7 @@ private static QueuedThreadPoolExecutor initExecutor(
139139 final EnvelopeSender envelopeSender = (EnvelopeSender ) r ;
140140
141141 if (!HintUtils .hasType (envelopeSender .hint , Cached .class )) {
142- envelopeCache .store (envelopeSender .envelope , envelopeSender .hint );
142+ envelopeCache .storeEnvelope (envelopeSender .envelope , envelopeSender .hint );
143143 }
144144
145145 markHintWhenSendingFailed (envelopeSender .hint , true );
@@ -268,7 +268,7 @@ public void run() {
268268 TransportResult result = this .failedResult ;
269269
270270 envelope .getHeader ().setSentAt (null );
271- envelopeCache .store (envelope , hint );
271+ boolean cached = envelopeCache .storeEnvelope (envelope , hint );
272272
273273 HintUtils .runIfHasType (
274274 hint ,
@@ -308,14 +308,17 @@ public void run() {
308308
309309 // ignore e.g. 429 as we're not the ones actively dropping
310310 if (result .getResponseCode () >= 400 && result .getResponseCode () != 429 ) {
311- HintUtils .runIfDoesNotHaveType (
312- hint ,
313- Retryable .class ,
314- (hint ) -> {
315- options
316- .getClientReportRecorder ()
317- .recordLostEnvelope (DiscardReason .NETWORK_ERROR , envelopeWithClientReport );
318- });
311+ if (!cached ) {
312+ HintUtils .runIfDoesNotHaveType (
313+ hint ,
314+ Retryable .class ,
315+ (hint ) -> {
316+ options
317+ .getClientReportRecorder ()
318+ .recordLostEnvelope (
319+ DiscardReason .NETWORK_ERROR , envelopeWithClientReport );
320+ });
321+ }
319322 }
320323
321324 throw new IllegalStateException (message );
@@ -329,10 +332,12 @@ public void run() {
329332 retryable .setRetry (true );
330333 },
331334 (hint , clazz ) -> {
332- LogUtils .logNotInstanceOf (clazz , hint , options .getLogger ());
333- options
334- .getClientReportRecorder ()
335- .recordLostEnvelope (DiscardReason .NETWORK_ERROR , envelopeWithClientReport );
335+ if (!cached ) {
336+ LogUtils .logNotInstanceOf (clazz , hint , options .getLogger ());
337+ options
338+ .getClientReportRecorder ()
339+ .recordLostEnvelope (DiscardReason .NETWORK_ERROR , envelopeWithClientReport );
340+ }
336341 });
337342 throw new IllegalStateException ("Sending the event failed." , e );
338343 }
@@ -345,10 +350,12 @@ public void run() {
345350 retryable .setRetry (true );
346351 },
347352 (hint , clazz ) -> {
348- LogUtils .logNotInstanceOf (clazz , hint , options .getLogger ());
349- options
350- .getClientReportRecorder ()
351- .recordLostEnvelope (DiscardReason .NETWORK_ERROR , envelope );
353+ if (!cached ) {
354+ LogUtils .logNotInstanceOf (clazz , hint , options .getLogger ());
355+ options
356+ .getClientReportRecorder ()
357+ .recordLostEnvelope (DiscardReason .NETWORK_ERROR , envelope );
358+ }
352359 });
353360 }
354361 return result ;
0 commit comments