Skip to content

Commit 7fb5550

Browse files
opensearch-trigger-bot[bot]github-actions[bot]Peter Alfonsi
authored
[Bugfix] Fix ICacheKeySerializerTests flakiness (#14564) (#14617)
* Fix testInvalidInput flakiness * Addressed andrross's comment * rerun security check --------- (cherry picked from commit f9512db) Signed-off-by: Peter Alfonsi <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Peter Alfonsi <[email protected]>
1 parent 22b73aa commit 7fb5550

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

server/src/test/java/org/opensearch/common/cache/serializer/ICacheKeySerializerTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ public void testInvalidInput() throws Exception {
4343
ICacheKeySerializer<BytesReference> serializer = new ICacheKeySerializer<>(keySer);
4444

4545
Random rand = Randomness.get();
46-
byte[] randomInput = new byte[1000];
47-
rand.nextBytes(randomInput);
48-
49-
assertThrows(OpenSearchException.class, () -> serializer.deserialize(randomInput));
46+
// The first thing the serializer reads is a VInt for the number of dimensions.
47+
// This is an invalid input for StreamInput.readVInt(), so we are guaranteed to have an exception
48+
assertThrows(OpenSearchException.class, () -> serializer.deserialize(new byte[] { -1, -1, -1, -1, -1 }));
5049
}
5150

5251
public void testDimNumbers() throws Exception {

0 commit comments

Comments
 (0)