From ed9eef92dd23dfd02d62e57e10e46a43f7c8bcb9 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 12 Aug 2015 16:42:22 +0200 Subject: [PATCH] [TEST] Fix off-by-one bug in corruptFile util function The upper bound must be 0-based since we are corrupting an offset into the file but it can be a 1-based length of the file which results in an uncorrupted file. --- core/src/test/java/org/elasticsearch/index/store/StoreTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/index/store/StoreTest.java b/core/src/test/java/org/elasticsearch/index/store/StoreTest.java index 524d069957a..d5f929e12ce 100644 --- a/core/src/test/java/org/elasticsearch/index/store/StoreTest.java +++ b/core/src/test/java/org/elasticsearch/index/store/StoreTest.java @@ -655,7 +655,7 @@ public class StoreTest extends ESTestCase { IndexOutput output = dir.createOutput(fileOut, IOContext.DEFAULT); long len = input.length(); byte[] b = new byte[1024]; - long broken = randomInt((int) len); + long broken = randomInt((int) len-1); long pos = 0; while (pos < len) { int min = (int) Math.min(input.length() - pos, b.length);