Skip to content

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Dec 31, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 31, 2025 16:30
@github-actions
Copy link

github-actions bot commented Dec 31, 2025

Copyright Validation Results
Total: 2 | Passed: 2 | Failed: 0 | Skipped: 0 | at: 2025-12-31 16:33:23 UTC | commit: 88c9beb

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/filter/IncrementalWriteFilter.java
  • marklogic-client-api/src/test/java/com/marklogic/client/datamovement/filter/IncrementalWriteTest.java

✅ All files have valid copyright headers!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling in the incremental write functionality by ensuring that failures during JSON canonicalization are properly logged while still allowing the write operation to proceed or fail based on the actual format of the content. The key change is the addition of comprehensive test coverage for invalid JSON scenarios and improved documentation around error handling behavior.

Key Changes:

  • Added test coverage for invalid JSON handling with and without explicit format specification
  • Enhanced error handling documentation in IncrementalWriteFilter
  • Refactored test setup to reduce code duplication

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
IncrementalWriteTest.java Added tests for invalid JSON scenarios, refactored test setup with shared state variables, and removed unused WriteBatcherTemplate utility class
IncrementalWriteFilter.java Updated comment to clarify error handling strategy when JSON canonicalization fails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to 41
List<DocumentWriteOperation> docs = new ArrayList<>();
IncrementalWriteFilter filter;

@BeforeEach
void setup() {
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs list is now shared across all test methods as instance state. This can lead to test pollution if not properly cleared between tests. Consider initializing it in the @BeforeEach method or making it local to each test method to ensure test isolation.

Suggested change
List<DocumentWriteOperation> docs = new ArrayList<>();
IncrementalWriteFilter filter;
@BeforeEach
void setup() {
List<DocumentWriteOperation> docs;
IncrementalWriteFilter filter;
@BeforeEach
void setup() {
// Ensure docs is reinitialized for each test to avoid shared state between tests.
docs = new ArrayList<>();

Copilot uses AI. Check for mistakes.
private void runTest() {
@Test
void invalidJsonWithNoFormat() {
docs.add(new DocumentWriteOperationImpl("/aaa.txt", METADATA, new StringHandle("{\"not actually json")));
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aaa' to a more descriptive test file name.

Copilot uses AI. Check for mistakes.

@Test
void invalidJsonWithFormat() {
docs.add(new DocumentWriteOperationImpl("/aaa.json", METADATA, new StringHandle("not actually json").withFormat(Format.JSON)));
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'aaa' to a more descriptive test file name.

Copilot uses AI. Check for mistakes.
@rjrudin rjrudin force-pushed the feature/26420-better-json branch from a96d910 to 88c9beb Compare December 31, 2025 16:33
@rjrudin rjrudin merged commit 0e6f0ae into develop Dec 31, 2025
3 checks passed
@rjrudin rjrudin deleted the feature/26420-better-json branch December 31, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants