Skip to content

Commit

Permalink
try/finally scope for tailers & appenders in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryShea committed Oct 15, 2023
1 parent c5e4e50 commit 30eef4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ static void doPerfTest(TestWriter<Bytes<?>> writer, TestReader<Bytes<?>> reader,
Histogram readHdr = new Histogram(30, 7);
String file = OS.getTarget() + "/deleteme-" + Time.uniqueId();
try (ChronicleQueue chronicle = single(file).blockSize(64 << 20).build();
ExcerptAppender appender = chronicle.createAppender()) {
ExcerptAppender appender = chronicle.createAppender();
ExcerptTailer tailer = chronicle.createTailer()) {
UncheckedBytes bytes = new UncheckedBytes(NoBytesStore.NO_BYTES);
for (int i = 0; i < count; i++) {
long start = System.nanoTime();
Expand All @@ -79,7 +80,6 @@ static void doPerfTest(TestWriter<Bytes<?>> writer, TestReader<Bytes<?>> reader,
writeHdr.sample(time);
}

ExcerptTailer tailer = chronicle.createTailer();
for (int i = 0; i < count; i++) {
long start2 = System.nanoTime();
try (DocumentContext dc = tailer.readingDocument()) {
Expand Down
33 changes: 17 additions & 16 deletions src/test/java/net/openhft/chronicle/queue/StridingAQueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,23 @@ public void testStriding() {

assertEquals(getExpected(), queue.dump().replaceAll("(?m)^#.+$\\n", ""));
StringWriter sw = new StringWriter();
ExcerptTailer tailer = queue.createTailer().direction(TailerDirection.BACKWARD).toEnd().striding(true);
MethodReader reader = tailer.methodReader(Mocker.logging(SAQMessage.class, "", sw));
while (reader.readOne()) ;
assertEquals("hi[4, 9]\n" +
"hi[4, 8]\n" +
"hi[4, 4]\n" +
"hi[4, 0]\n" +
"hi[3, 8]\n" +
"hi[3, 4]\n" +
"hi[3, 0]\n" +
"hi[2, 7]\n" +
"hi[2, 5]\n" +
"hi[2, 1]\n" +
"hi[1, 4]\n" +
"hi[1, 0]\n",
sw.toString().replace("\r", ""));
try (ExcerptTailer tailer = queue.createTailer().direction(TailerDirection.BACKWARD).toEnd().striding(true)) {
MethodReader reader = tailer.methodReader(Mocker.logging(SAQMessage.class, "", sw));
while (reader.readOne()) ;
assertEquals("hi[4, 9]\n" +
"hi[4, 8]\n" +
"hi[4, 4]\n" +
"hi[4, 0]\n" +
"hi[3, 8]\n" +
"hi[3, 4]\n" +
"hi[3, 0]\n" +
"hi[2, 7]\n" +
"hi[2, 5]\n" +
"hi[2, 1]\n" +
"hi[1, 4]\n" +
"hi[1, 0]\n",
sw.toString().replace("\r", ""));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ private void doTest(@NotNull String... problematic) {
.blockSize(Maths.nextPower2(EXTREMELY_LARGE.length() * 4, 256 << 10))
// .testBlockSize() not suitable as large message sizes.
.build();
ExcerptAppender appender = theQueue.createAppender()) {

ExcerptTailer tailer = theQueue.createTailer();
ExcerptAppender appender = theQueue.createAppender();
ExcerptTailer tailer = theQueue.createTailer()) {

StringBuilder tmpReadback = new StringBuilder();

Expand Down

0 comments on commit 30eef4a

Please sign in to comment.