Skip to content

Commit 995a9d7

Browse files
Fix flaky test ChunkLinkDownloadServiceTest#testBatchDownloadChaining (#811)
The link download futures were being completed because the link download chain was triggered eagerly. When getLinkForChunk is called, the link download future is evaluated. If the future is already complete, it checks the status of the chunk. The test was not mocking the chunk, which caused a NullPointerException (NPE). Locally, the test passed because the link download futures weren't completing before getLinkForChunk was called. However, in the GitHub runs, the futures were completing, which led to a thread synchronization issue.
1 parent 2f2814c commit 995a9d7

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/test/java/com/databricks/jdbc/api/impl/arrow/ChunkLinkDownloadServiceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ void testBatchDownloadChaining()
206206
createExternalLink("test-url", 5L, Collections.emptyMap(), "2025-02-16T00:00:00Z");
207207
ExternalLink linkForChunkIndex_6 =
208208
createExternalLink("test-url", 6L, Collections.emptyMap(), "2025-02-16T00:00:00Z");
209+
210+
ArrowResultChunk mockChunk = mock(ArrowResultChunk.class);
211+
when(mockChunkMap.get(anyLong())).thenReturn(mockChunk);
209212
when(mockSession.getDatabricksClient()).thenReturn(mockClient);
210213
// Mock the links for the first batch. The link futures for both chunks will be completed at the
211214
// same time

0 commit comments

Comments
 (0)