Skip to content

Commit 1e744a3

Browse files
committed
Not logging message when no documents fail
1 parent 970a2ef commit 1e744a3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/com/marklogic/spark/writer/WriteBatcherDataWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ private ZipFileWriter createArchiveWriter(SerializableConfiguration hadoopConfig
228228

229229
private void closeArchiveWriter() {
230230
if (archiveWriter != null) {
231-
Util.MAIN_LOGGER.info("Wrote failed documents to archive file at {}.", archiveWriter.getZipPath());
231+
if (failedItemCount.get() > 0) {
232+
Util.MAIN_LOGGER.info("Wrote failed documents to archive file at {}.", archiveWriter.getZipPath());
233+
}
232234
archiveWriter.close();
233235
}
234236
}

src/test/java/com/marklogic/spark/writer/WriteArchiveOfFailedDocumentsTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import java.util.Map;
2222
import java.util.concurrent.atomic.AtomicInteger;
2323

24-
import static org.junit.jupiter.api.Assertions.*;
24+
import static org.junit.jupiter.api.Assertions.assertEquals;
25+
import static org.junit.jupiter.api.Assertions.assertTrue;
2526

2627
class WriteArchiveOfFailedDocumentsTest extends AbstractWriteTest {
2728

@@ -64,6 +65,18 @@ void happyPath(@TempDir Path tempDir) {
6465
verifyArchiveRows(rows);
6566
}
6667

68+
@Test
69+
void noFailures(@TempDir Path tempDir) {
70+
newWriter(1)
71+
.option(Options.WRITE_ABORT_ON_FAILURE, false)
72+
.option(Options.WRITE_ARCHIVE_PATH_FOR_FAILED_DOCUMENTS, tempDir.toFile().getAbsolutePath())
73+
.save();
74+
75+
assertCollectionSize("This test is for manual inspection of the logs to ensure that no message is " +
76+
"logged indicating that an archive file of failed documents was written when there are no errors.",
77+
COLLECTION, 200);
78+
}
79+
6780
@Test
6881
void multiplePartitions(@TempDir Path tempDir) {
6982
defaultWrite(newSparkSession().read().format(CONNECTOR_IDENTIFIER)

0 commit comments

Comments
 (0)