Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,31 @@ public void additionalHeadersIncludedInEventsRequest() throws IOException, Inter
}
}

@Test
public void testEventBufferFillsUp() throws IOException, InterruptedException {
try (MockWebServer mockEventsServer = new MockWebServer()) {
mockEventsServer.start();
// Enqueue a successful empty response
mockEventsServer.enqueue(new MockResponse());

LDConfig ldConfig = baseConfigBuilder(mockEventsServer)
.eventsCapacity(1)
.build();

// Don't wait as we are not set offline
try (LDClient client = LDClient.init(application, ldConfig, ldUser, 0)) {
client.identify(ldUser);
LDValue testData = LDValue.of("xyz");
client.trackData("test-event", testData);
client.blockingFlush();

// Verify that only the first event was sent and other events were dropped
Event[] events = getEventsFromLastRequest(mockEventsServer, 1);
assertTrue(events[0] instanceof IdentifyEvent);
}
}
}

private Event[] getEventsFromLastRequest(MockWebServer server, int expectedCount) throws InterruptedException {
RecordedRequest r = server.takeRequest();
assertEquals("POST", r.getMethod());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ private void sendEvent(Event event) {
boolean processed = eventProcessor.sendEvent(event);
if (!processed) {
LDConfig.LOG.w("Exceeded event queue capacity. Increase capacity to avoid dropping events.");
diagnosticStore.incrementDroppedEventCount();
if (diagnosticStore != null) {
diagnosticStore.incrementDroppedEventCount();
}
}
}
}
Expand Down