vcrfxia commented on code in PR #13431: URL: https://github.com/apache/kafka/pull/13431#discussion_r1151100435
########## streams/src/test/java/org/apache/kafka/streams/state/internals/LogicalKeyValueSegmentTest.java: ########## @@ -172,30 +227,77 @@ public void shouldReturnValuesOnRange() { final KeyValue<String, String> kv2 = new KeyValue<>("2", "two"); final KeyValue<String, String> kvOther = new KeyValue<>("1", "other"); - segment2.put(new Bytes(serializeBytes(kv0.key)), serializeBytes(kv0.value)); - segment2.put(new Bytes(serializeBytes(kv1.key)), serializeBytes(kv1.value)); - segment2.put(new Bytes(serializeBytes(kv2.key)), serializeBytes(kv2.value)); - segment1.put(new Bytes(serializeBytes(kvOther.key)), serializeBytes(kvOther.value)); - segment3.put(new Bytes(serializeBytes(kvOther.key)), serializeBytes(kvOther.value)); + segment1.put(new Bytes(serializeBytes(kv0.key)), serializeBytes(kv0.value)); + segment1.put(new Bytes(serializeBytes(kv1.key)), serializeBytes(kv1.value)); + segment1.put(new Bytes(serializeBytes(kv2.key)), serializeBytes(kv2.value)); + segment0.put(new Bytes(serializeBytes(kvOther.key)), serializeBytes(kvOther.value)); + segment2.put(new Bytes(serializeBytes(kvOther.key)), serializeBytes(kvOther.value)); + + // non-null bounds + try (final KeyValueIterator<Bytes, byte[]> iterator = segment1.range(new Bytes(serializeBytes("1")), new Bytes(serializeBytes("2")))) { + final LinkedList<KeyValue<String, String>> expectedContents = new LinkedList<>(); + expectedContents.add(kv1); + expectedContents.add(kv2); + assertEquals(expectedContents, getDeserializedList(iterator)); + } + + // null lower bound + try (final KeyValueIterator<Bytes, byte[]> iterator = segment1.range(null, new Bytes(serializeBytes("1")))) { + final LinkedList<KeyValue<String, String>> expectedContents = new LinkedList<>(); + expectedContents.add(kv0); + expectedContents.add(kv1); + assertEquals(expectedContents, getDeserializedList(iterator)); + } + + // null upper bound + try (final KeyValueIterator<Bytes, byte[]> iterator = segment1.range(new Bytes(serializeBytes("0")), null)) { + final LinkedList<KeyValue<String, String>> expectedContents = new LinkedList<>(); + expectedContents.add(kv0); + expectedContents.add(kv1); + expectedContents.add(kv2); + assertEquals(expectedContents, getDeserializedList(iterator)); + } + + // null upper and lower bounds + try (final KeyValueIterator<Bytes, byte[]> iterator = segment1.range(new Bytes(serializeBytes("0")), null)) { Review Comment: Good catch! Fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org