diff --git a/src/main/java/net/openhft/chronicle/queue/impl/single/StoreTailer.java b/src/main/java/net/openhft/chronicle/queue/impl/single/StoreTailer.java index c0d1f3fb42..68805bbf4a 100644 --- a/src/main/java/net/openhft/chronicle/queue/impl/single/StoreTailer.java +++ b/src/main/java/net/openhft/chronicle/queue/impl/single/StoreTailer.java @@ -919,7 +919,7 @@ private ExcerptTailer callOriginalToEnd() { queue.refreshDirectoryListing(); // due to a race condition, where the queue rolls as we are processing toEnd() // we may get a NotReachedException ( see https://github.com/OpenHFT/Chronicle-Queue/issues/702 ) - // hence are are just going to retry. + // hence we are just going to retry. try { return originalToEnd(); } catch (Exception ex) { diff --git a/src/test/java/net/openhft/chronicle/queue/impl/single/StoreTailerTest.java b/src/test/java/net/openhft/chronicle/queue/impl/single/StoreTailerTest.java index a7734ba062..81ab015a13 100644 --- a/src/test/java/net/openhft/chronicle/queue/impl/single/StoreTailerTest.java +++ b/src/test/java/net/openhft/chronicle/queue/impl/single/StoreTailerTest.java @@ -586,4 +586,71 @@ public void run() throws InterruptedException { } } } + + @Test(expected = IllegalStateException.class) + public void cantMoveToStartDuringDocumentReading() { + File dir = getTmpDir(); + try (SingleChronicleQueue queue = ChronicleQueue.singleBuilder(dir).build(); + ExcerptTailer tailer = queue.createTailer(); + ExcerptAppender appender = queue.createAppender()) { + appender.writeText("Hello World"); + try (DocumentContext dc = tailer.readingDocument(true)) { + assertTrue(dc.isPresent()); + assertTrue(dc.isMetaData()); + assertEquals("header", dc.wire().readEvent(String.class)); + assertTrue(tailer.toString().contains("StoreTailer{")); + tailer.toStart();//forbidden + } + } + } + + @Test(expected = IllegalStateException.class) + public void cantMoveToEndDuringDocumentReading() { + File dir = getTmpDir(); + try (SingleChronicleQueue queue = ChronicleQueue.singleBuilder(dir).build(); + ExcerptTailer tailer = queue.createTailer(); + ExcerptAppender appender = queue.createAppender()) { + appender.writeText("Hello World"); + try (DocumentContext dc = tailer.readingDocument(true)) { + assertTrue(dc.isPresent()); + assertTrue(dc.isMetaData()); + assertEquals("header", dc.wire().readEvent(String.class)); + assertTrue(tailer.toString().contains("StoreTailer{")); + tailer.toEnd();//forbidden + } + } + } + + @Test + public void testStriding() { + File dir = getTmpDir(); + try (SingleChronicleQueue queue = ChronicleQueue.singleBuilder(dir).build(); + ExcerptTailer tailer = queue.createTailer()) { + tailer.striding(true); + assertTrue(tailer.striding()); + } + } + + @Test + public void testMoveToIndex() { + File dir = getTmpDir(); + try (SingleChronicleQueue queue = ChronicleQueue.singleBuilder(dir).build(); + ExcerptTailer tailer = queue.createTailer(); + ExcerptAppender appender = queue.createAppender()) { + appender.writeText("Hello World"); + try (DocumentContext dc = tailer.readingDocument()) { + tailer.moveToIndex(tailer.index() + 1); + } + } + } + + @Test + public void testExcerptsInCycle() { + File dir = getTmpDir(); + try (SingleChronicleQueue queue = ChronicleQueue.singleBuilder(dir).build(); + ExcerptTailer tailer = queue.createTailer()) { + tailer.excerptsInCycle(tailer.cycle()); + } + } + }