Skip to content

Commit d76ef16

Browse files
glasstigerclaude
andcommitted
Fix Windows path split in orphan-tail drainer test
testPreAdoptionSetupFailureDoesNotQuarantineTheSlot derived the slot's parent directory with slotPath.substring(0, slotPath.lastIndexOf('/')). File.getAbsolutePath() yields '\' separators on Windows, so lastIndexOf returned -1 and substring threw StringIndexOutOfBoundsException before the test reached a single assertion. It was the only failure in the Windows CI run (2684 tests, 1 error). Paths.get(slotPath).getParent() derives the parent portably. The join stays a forward slash on purpose: SlotLock.resolveLogicalLock builds the lock directory as parentPath + "/" + ".slot-locks", and the blocking file this test plants must land on the exact string acquireLogical will mkdir. Deriving the whole path through Paths.get would yield '\.slot-locks' on Windows, putting the file where acquireLogical never looks, so the test would pass while exercising nothing. SlotLockTest already documents that trap for its sibling. Verified both ways on macOS: the test passes with this change, and still fails with "a slot this drainer never adopted must not be quarantined" when the BackgroundDrainer engine != null guard it pins is reverted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 54cb19d commit d76ef16

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

core/src/test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor/BackgroundDrainerOrphanTailTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.junit.Test;
3636
import org.junit.rules.TemporaryFolder;
3737

38+
import java.nio.file.Paths;
3839
import java.util.concurrent.atomic.AtomicInteger;
3940

4041
import static org.junit.Assert.assertEquals;
@@ -108,7 +109,12 @@ public void testPreAdoptionSetupFailureDoesNotQuarantineTheSlot() throws Excepti
108109
try (CursorSendEngine engine = new CursorSendEngine(slotPath, SEGMENT_SIZE_BYTES)) {
109110
appendDeferredFrame(engine);
110111
}
111-
String parent = slotPath.substring(0, slotPath.lastIndexOf('/'));
112+
// Derive the parent with Paths.get (portable: getAbsolutePath yields '\'
113+
// separators on Windows, so lastIndexOf('/') returns -1 and substring
114+
// throws), then join with a FORWARD slash -- SlotLock.resolveLogicalLock
115+
// builds `parentPath + "/" + ".slot-locks"` exactly that way, and the
116+
// blocking file must land on the same string acquireLogical will mkdir.
117+
String parent = Paths.get(slotPath).getParent().toString();
112118
String lockDirPath = parent + "/.slot-locks";
113119
int fd = Files.openRW(lockDirPath);
114120
assertTrue("could not plant the blocking file", fd > -1);

0 commit comments

Comments
 (0)