-
Notifications
You must be signed in to change notification settings - Fork 18
Backmerge CommCare 2.60 #1507
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
Backmerge CommCare 2.60 #1507
Conversation
Changes to facilititate more error response logging on mobile
WalkthroughHTTP error handling is enhanced by adding error response stream access. The Changes
Sequence DiagramsequenceDiagram
participant Client
participant ModernHttpRequester
participant HttpResponseProcessor
participant ResponseCache
Client->>ModernHttpRequester: HTTP Request (4xx response)
ModernHttpRequester->>ResponseCache: cacheResponse(body)
ResponseCache-->>ModernHttpRequester: cached InputStream
alt Error stream present
ModernHttpRequester->>ModernHttpRequester: getErrorResponseStream()
ModernHttpRequester->>ResponseCache: cacheResponse(errorBody)
ResponseCache-->>ModernHttpRequester: errorInputStream
ModernHttpRequester->>HttpResponseProcessor: processClientError(responseCode, errorInputStream)
else Error stream read fails
ModernHttpRequester->>ModernHttpRequester: Log exception
ModernHttpRequester->>HttpResponseProcessor: processClientError(responseCode, null)
end
HttpResponseProcessor-->>Client: Error handled
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The changes involve interface signature updates requiring implementation consistency checks, new caching logic in Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/org/commcare/core/network/ModernHttpRequester.java (1)
16-16: Unused import detected.The
StandardCharsetsimport doesn't appear to be used anywhere in this file.Apply this diff to remove the unused import:
-import java.nio.charset.StandardCharsets;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/main/java/org/commcare/core/interfaces/HttpResponseProcessor.java(1 hunks)src/main/java/org/commcare/core/interfaces/ResponseStreamAccessor.java(1 hunks)src/main/java/org/commcare/core/network/ModernHttpRequester.java(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/org/commcare/core/network/ModernHttpRequester.java (1)
src/main/java/org/javarosa/core/services/Logger.java (1)
Logger(10-101)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: task-list-completed
🔇 Additional comments (6)
src/main/java/org/commcare/core/interfaces/ResponseStreamAccessor.java (1)
6-12: LGTM! Interface extension looks good.The new
getErrorResponseStream()method is appropriately annotated with@Nullablesince error response streams may not always be available. The method signature is consistent with the existinggetResponseStream()method.src/main/java/org/commcare/core/network/ModernHttpRequester.java (4)
104-108: LGTM! Implementation follows established pattern.The
getErrorResponseStream()implementation correctly delegates to the requester's method and follows the same pattern as the existinggetResponseStream()method.
186-194: Error stream handling looks solid.The error handling logic properly:
- Retrieves the error stream
- Passes it to the processor
- Logs any exceptions during error processing
- Ensures the stream is closed via the finally block
The broad
Exceptioncatch on line 190 is acceptable here since this is error-path code where preventing crashes during error processing is more important than failing fast.
208-220: Excellent refactoring to eliminate duplication.Extracting the
cacheResponsemethod is a good improvement that allows both response and error streams to share the same caching logic, improving maintainability.
222-228: LGTM! Error response caching implemented correctly.The method properly checks for a non-null error body before caching and correctly returns
nullotherwise, matching the@Nullablecontract from the interface.src/main/java/org/commcare/core/interfaces/HttpResponseProcessor.java (1)
23-23: Verify that external implementations of HttpResponseProcessor have been updated.The breaking change to the
HttpResponseProcessorinterface has been applied (newInputStream errorStreamparameter added), and the sole call site in this codebase (ModernHttpRequester.java:189) correctly uses the new 2-parameter signature. However, no implementing classes were found within this codebase. Since this interface appears to be consumed by external projects, ensure all downstream implementations outside this repository have been updated to match the new signature.
Product Description
Backmerge CommCare 2.60
Summary by CodeRabbit
Bug Fixes
Performance