You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2022/10/31 16:47:56 UTC
[solr] branch branch_9x updated: SOLR-16511: Make sure no array/list index can be -1 (#1153)
This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 1b77c83e1fe SOLR-16511: Make sure no array/list index can be -1 (#1153)
1b77c83e1fe is described below
commit 1b77c83e1fe45cb67a59c4d2db60e4b4b69dec0c
Author: Houston Putman <ho...@apache.org>
AuthorDate: Mon Oct 31 12:44:30 2022 -0400
SOLR-16511: Make sure no array/list index can be -1 (#1153)
(cherry picked from commit 67034a5a55d1eeaf07508c1505da8be420ae8758)
---
.../solr/cloud/api/collections/AbstractIncrementalBackupTest.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java
index 14bfedee455..7258915bcd7 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java
@@ -349,7 +349,7 @@ public abstract class AbstractIncrementalBackupTest extends SolrCloudTestCase {
protected void corruptIndexFiles() throws IOException {
List<Slice> slices = new ArrayList<>(getCollectionState(getCollectionName()).getSlices());
- Replica leader = slices.get(random().nextInt(slices.size()) - 1).getLeader();
+ Replica leader = slices.get(random().nextInt(slices.size())).getLeader();
JettySolrRunner leaderNode = cluster.getReplicaJetty(leader);
final Path fileToCorrupt;
@@ -367,12 +367,14 @@ public abstract class AbstractIncrementalBackupTest extends SolrCloudTestCase {
if (indexFiles.isEmpty()) {
return;
}
- fileToCorrupt = indexFiles.get(random().nextInt(indexFiles.size()) - 1);
+ fileToCorrupt = indexFiles.get(random().nextInt(indexFiles.size()));
}
final byte[] contents = Files.readAllBytes(fileToCorrupt);
for (int i = 1; i < 5; i++) {
int key = contents.length - CodecUtil.footerLength() - i;
- contents[key] = (byte) (contents[key] + 1);
+ if (key >= 0) {
+ contents[key] = (byte) (contents[key] + 1);
+ }
}
Files.write(fileToCorrupt, contents);
}