You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/10/31 16:38:33 UTC

[GitHub] [solr] risdenk commented on a diff in pull request #1153: SOLR-16511: Make sure no array/list index can be -1

risdenk commented on code in PR #1153:
URL: https://github.com/apache/solr/pull/1153#discussion_r1009630226


##########
solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java:
##########
@@ -367,12 +367,14 @@ protected void corruptIndexFiles() throws IOException {
       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) {

Review Comment:
   thats a good idea.



##########
solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java:
##########
@@ -367,12 +367,14 @@ protected void corruptIndexFiles() throws IOException {
       if (indexFiles.isEmpty()) {
         return;
       }
-      fileToCorrupt = indexFiles.get(random().nextInt(indexFiles.size()) - 1);
+      fileToCorrupt = indexFiles.get(random().nextInt(indexFiles.size()));

Review Comment:
   Ugh I swear nextInt was 1 -> some upperbound.
   
   https://docs.oracle.com/javase/8/docs/api/java/util/Random.html#nextInt-int-
   
   but I am 100% wrong there.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org