Repository navigation
feat: replace permanent event-delivery disable with a bounded cooldown #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
828021b
0cd76e2
f40324a
8358410
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import com.launchdarkly.logging.LDLogger; | ||
| import com.launchdarkly.logging.LogValues; | ||
| import com.launchdarkly.sdk.internal.http.FailureClass; | ||
| import com.launchdarkly.sdk.internal.http.HttpHelpers; | ||
| import com.launchdarkly.sdk.internal.http.HttpProperties; | ||
|
|
||
|
|
@@ -16,7 +17,7 @@ | |
| import java.util.UUID; | ||
| import java.util.zip.GZIPOutputStream; | ||
|
|
||
| import static com.launchdarkly.sdk.internal.http.HttpErrors.checkIfErrorIsRecoverableAndLog; | ||
| import static com.launchdarkly.sdk.internal.http.HttpErrors.classifyHttpFailure; | ||
| import static com.launchdarkly.sdk.internal.http.HttpErrors.httpErrorDescription; | ||
|
|
||
| import okhttp3.Headers; | ||
|
|
@@ -152,7 +153,7 @@ private CompressionResult<byte[]> compressData(byte[] data) { | |
| private Result sendEventData(boolean isDiagnostic, byte[] data, int eventCount, URI eventsBaseUri) { | ||
| if (data == null || data.length == 0) { | ||
| // DefaultEventProcessor won't normally pass us an empty payload, but if it does, don't bother sending | ||
| return new Result(true, false, null); | ||
| return Result.success(null); | ||
| } | ||
|
|
||
| Headers.Builder headersBuilder = baseHeaders.newBuilder(); | ||
|
|
@@ -173,7 +174,7 @@ private Result sendEventData(boolean isDiagnostic, byte[] data, int eventCount, | |
| URI uri = HttpHelpers.concatenateUriPath(eventsBaseUri, path); | ||
| CompressionResult<byte[]> compressionResult = compressData(data); | ||
| RequestBody body = RequestBody.create(compressionResult.data, JSON_CONTENT_TYPE); | ||
| boolean mustShutDown = false; | ||
| boolean unexpected = false; | ||
|
|
||
| if (compressionResult.wasCompressed) { | ||
| headersBuilder.add("Content-Encoding", "gzip"); | ||
|
|
@@ -207,27 +208,24 @@ private Result sendEventData(boolean isDiagnostic, byte[] data, int eventCount, | |
| logger.debug("{} delivery took {} ms, response status {}", description, endTime - startTime, response.code()); | ||
|
|
||
| if (response.isSuccessful()) { | ||
| return new Result(true, false, parseResponseDate(response)); | ||
| return Result.success(parseResponseDate(response)); | ||
| } | ||
|
|
||
| String errorDesc = httpErrorDescription(response.code()); | ||
| boolean recoverable = checkIfErrorIsRecoverableAndLog( | ||
| logger, | ||
| errorDesc, | ||
| errorContext, | ||
| response.code(), | ||
| nextActionMessage | ||
| ); | ||
| if (!recoverable) { | ||
| mustShutDown = true; | ||
| if (classifyHttpFailure(response.code()) == FailureClass.UNEXPECTED) { | ||
| logger.error("Error {} (the payload will not be retried): {}", errorContext, errorDesc); | ||
| unexpected = true; | ||
| break; | ||
| } | ||
| logger.warn("Error {} ({}): {}", errorContext, nextActionMessage, errorDesc); | ||
| } catch (IOException e) { | ||
| checkIfErrorIsRecoverableAndLog(logger, e.toString(), errorContext, 0, nextActionMessage); | ||
| // Transport-level failures are always worth one retry here, whatever their cause; the | ||
| // request may simply have hit a transient network problem. | ||
| logger.warn("Error {} ({}): {}", errorContext, nextActionMessage, e.toString()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Transport errors log unsanitized exceptionsMedium Severity The new IOException warn path logs Triggered by learned rule: Log exceptions with LogValues.exceptionSummary, not toString/getMessage Reviewed by Cursor Bugbot for commit 8358410. Configure here. |
||
| } | ||
| } | ||
|
|
||
| return new Result(false, mustShutDown, null); | ||
| return unexpected ? Result.unexpectedFailure() : Result.failure(); | ||
| } | ||
|
|
||
| private final Date parseResponseDate(Response response) { | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null sender result skips failure recording
Low Severity
A custom
EventSenderthat returns null still only trips the outer catch aroundhandleResponse. That catch keeps the worker alive but never callsrecordFailure, so the consecutive-success streak is left intact. The PR contract treats a null result as an ordinary failure that should break the reset threshold the same way a thrown sender does.Additional Locations (1)
lib/shared/internal/src/main/java/com/launchdarkly/sdk/internal/events/DefaultEventProcessor.java#L687-L700Reviewed by Cursor Bugbot for commit 8358410. Configure here.