initial commit #4
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Instana Android agent version 6.0.23, there is an issue where requests are being duplicated. This occurs when any Exception happens during the execution of a network request, regardless of whether the request was modified by Instana itself. That is, if any interceptor generates an exception, the mechanism implemented in OkHttp3GlobalInterceptor initiates a repeat request.
Purpose: This interceptor is responsible for processing network requests, and its logic includes restarting requests when errors occur.
Trigger Logic: If any exception occurs during request execution, regardless of its source, the interceptor considers the request incorrectly executed and initiates a retry.
Consequences: A repeat request is sent even when the original request was not modified. This is not obvious to developers who may expect the logic of underlying interceptors to execute without fear of duplicate calls.
Disruption of Expected Behavior: Lower-level interceptors responsible for error handling may generate exceptions for incorrect HTTP codes or other issues. However, their exceptions automatically lead to request retries, which may not align with the application's logic.
Breaking the Processing Chain: Errors handled by lower layers are expected to be correctly propagated upward. But if an exception leads to a repeat request, this can disrupt internal error handling logic and cause duplicate actions.
Current Implementation Problem
The interceptor's current implementation has a catch-all exception handler that unconditionally performs a second request when any exception occurs:
My solution was to add a configurable flag in InstanaConfig.kt