Skip to content

Commit 08f3fa8

Browse files
CribbeeXiaoHongbo-Hope
authored andcommitted
[core] Add interrupt coverage for snapshot existence retries (#9745)
1 parent 6111a4d commit 08f3fa8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎paimon-core/src/test/java/org/apache/paimon/utils/SnapshotManagerTest.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,25 @@ public void testSnapshotExistsFailsAfterMaxAttempts() throws IOException {
121121
Mockito.verify(fileIO, Mockito.times(3)).exists(Mockito.any(Path.class));
122122
}
123123

124+
@Test
125+
public void testSnapshotExistsRestoresInterruptedStatus() throws IOException {
126+
FileIO fileIO = Mockito.mock(FileIO.class);
127+
Mockito.when(fileIO.exists(Mockito.any(Path.class)))
128+
.thenThrow(new IOException("Temporary failure"));
129+
SnapshotManager snapshotManager = newSnapshotManager(fileIO, new Path(tempDir.toString()));
130+
131+
Thread.currentThread().interrupt();
132+
try {
133+
assertThatThrownBy(() -> snapshotManager.snapshotExists(2))
134+
.hasMessageContaining("Interrupted while checking whether snapshot #2 exists")
135+
.hasCauseInstanceOf(InterruptedException.class);
136+
assertThat(Thread.currentThread().isInterrupted()).isTrue();
137+
Mockito.verify(fileIO).exists(Mockito.any(Path.class));
138+
} finally {
139+
Thread.interrupted();
140+
}
141+
}
142+
124143
@ParameterizedTest
125144
@ValueSource(booleans = {true, false})
126145
public void testEarliestSnapshot(boolean isRaceCondition) throws IOException {

0 commit comments

Comments
 (0)