Conversation
|
Copyright Validation Results ⏭️ Skipped (Excluded) Files
✅ Valid Files
✅ All files have valid copyright headers! |
There was a problem hiding this comment.
Pull request overview
Adds a new JUnit test class intended to validate OkHttp-based retry behavior on 50x responses, and adjusts retry logging so that retry attempts are logged under RetryContext (with corresponding test logback configuration).
Changes:
- Added
RetryOn50XResponseTestthat uses a custom OkHttp interceptor to simulate 502 responses and observe retries. - Refactored
RetryContextto use its own SLF4J logger (viaLoggerFactory) instead of receiving a logger instance. - Updated OkHttpServices call sites to use the new
RetryContextconstructor and enabled DEBUG logging forRetryContextinlogback-test.xml.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
marklogic-client-api/src/test/resources/logback-test.xml |
Enables DEBUG logging for RetryContext during tests. |
marklogic-client-api/src/test/java/com/marklogic/client/impl/okhttp/RetryOn50XResponseTest.java |
Adds tests for retry-on-502 behavior via an interceptor. |
marklogic-client-api/src/main/java/com/marklogic/client/impl/RetryContext.java |
Switches retry logging to a class-level logger (no longer injected). |
marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java |
Updates RetryContext instantiations to match the new constructor signature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @BeforeEach | ||
| void setUp() { | ||
| // Configure very short retry delays for testing | ||
| System.setProperty("com.marklogic.client.retry.maxDelay", "3"); | ||
| System.setProperty("com.marklogic.client.retry.minRetry", "2"); | ||
|
|
||
| // "Touch" the Common class to trigger the static block that removes existing configurators on | ||
| // DatabaseClientFactory. | ||
| Common.newServerPayload(); | ||
| } |
There was a problem hiding this comment.
The test sets system properties com.marklogic.client.retry.maxDelay and com.marklogic.client.retry.minRetry, but OkHttpServices reads retry settings from RESTServices.MAX_DELAY_PROP (com.marklogic.client.maximumRetrySeconds) and RESTServices.MIN_RETRY_PROP (com.marklogic.client.minimumRetries). As-is, the test will run with defaults (up to ~120s retry window / 8 minimum retries), which can make it very slow/flaky and may not validate the intended behavior. Update the test to set/clear the actual property keys used by the retry logic (and keep in mind max delay is in seconds, not ms).
| // "Touch" the Common class to trigger the static block that removes existing configurators on | ||
| // DatabaseClientFactory. | ||
| Common.newServerPayload(); |
There was a problem hiding this comment.
Common.newServerPayload() is used here only to force Common's static initializer to run and clear existing configurators. That initializer will only run once per JVM, so subsequent test methods won't get any reset behavior from this call. For better test isolation, consider explicitly calling DatabaseClientFactory.removeConfigurators() (and then adding only the configurators this test needs) instead of relying on a one-time class initialization side effect.
| // "Touch" the Common class to trigger the static block that removes existing configurators on | |
| // DatabaseClientFactory. | |
| Common.newServerPayload(); | |
| // Explicitly remove any previously registered configurators to ensure test isolation. | |
| DatabaseClientFactory.removeConfigurators(); |
| <appender-ref ref="STDOUT" /> | ||
| </logger> | ||
|
|
||
| <logger name="com.marklogic.client.impl.RetryContext" level="DEBUG" additivity="false"> |
There was a problem hiding this comment.
Adding a DEBUG logger for RetryContext in the shared logback-test.xml will enable verbose retry logging for the entire test suite. If this is only needed while developing/debugging this new test (and the test does not assert on logs), consider removing it or scoping it to just this test to avoid noisy CI output.
| <logger name="com.marklogic.client.impl.RetryContext" level="DEBUG" additivity="false"> | |
| <logger name="com.marklogic.client.impl.RetryContext" level="WARN" additivity="false"> |
bec224e to
ec45dd6
Compare
No description provided.