Skip to content

Commit ec9d435

Browse files
peteralfonsiPeter Alfonsi
authored andcommitted
[Bugfix] Fix ICacheKeySerializerTests flakiness (opensearch-project#14564)
* Fix testInvalidInput flakiness Signed-off-by: Peter Alfonsi <petealft@amazon.com> * Addressed andrross's comment Signed-off-by: Peter Alfonsi <petealft@amazon.com> * rerun security check Signed-off-by: Peter Alfonsi <petealft@amazon.com> --------- Signed-off-by: Peter Alfonsi <petealft@amazon.com> Co-authored-by: Peter Alfonsi <petealft@amazon.com> Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
1 parent 153134d commit ec9d435

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

+3-4
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)