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/30 19:05:29 UTC

[GitHub] [solr] risdenk opened a new pull request, #1152: SOLR-16511: Fix key in AbstractIncrementalBackupTest.corruptIndexFiles

risdenk opened a new pull request, #1152:
URL: https://github.com/apache/solr/pull/1152

   https://issues.apache.org/jira/browse/SOLR-16511


-- 
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


[GitHub] [solr] risdenk merged pull request #1152: SOLR-16511: Fix key in AbstractIncrementalBackupTest.corruptIndexFiles

Posted by GitBox <gi...@apache.org>.
risdenk merged PR #1152:
URL: https://github.com/apache/solr/pull/1152


-- 
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


[GitHub] [solr] sonatype-lift[bot] commented on a diff in pull request #1152: SOLR-16511: Fix key in AbstractIncrementalBackupTest.corruptIndexFiles

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1152:
URL: https://github.com/apache/solr/pull/1152#discussion_r1008923692


##########
solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractIncrementalBackupTest.java:
##########
@@ -350,31 +348,33 @@ public void testBackupIncremental() throws Exception {
   }
 
   protected void corruptIndexFiles() throws IOException {
-    Collection<Slice> slices = getCollectionState(getCollectionName()).getSlices();
-    Slice slice = slices.iterator().next();
-    JettySolrRunner leaderNode = cluster.getReplicaJetty(slice.getLeader());
-
-    SolrCore solrCore = leaderNode.getCoreContainer().getCore(slice.getLeader().getCoreName());
-    Set<String> fileNames =
-        new HashSet<>(solrCore.getDeletionPolicy().getLatestCommit().getFileNames());
-    File indexFolder = new File(solrCore.getIndexDir());
-    File fileGetCorrupted =
-        Stream.of(Objects.requireNonNull(indexFolder.listFiles()))
-            .filter(x -> fileNames.contains(x.getName()))
-            .findAny()
-            .get();
-    try (FileInputStream fis = new FileInputStream(fileGetCorrupted)) {
-      byte[] contents = fis.readAllBytes();
-      for (int i = 1; i < 5; i++) {
-        byte key = (byte) (contents.length - CodecUtil.footerLength() - i);
-        contents[key] = (byte) (contents[key] + 1);
+    List<Slice> slices = new ArrayList<>(getCollectionState(getCollectionName()).getSlices());
+    Replica leader = slices.get(random().nextInt(slices.size()) - 1).getLeader();
+    JettySolrRunner leaderNode = cluster.getReplicaJetty(leader);
+
+    final Path fileToCorrupt;
+    try (SolrCore solrCore = leaderNode.getCoreContainer().getCore(leader.getCoreName())) {

Review Comment:
   *NULL_DEREFERENCE:*  object returned by `leaderNode.getCoreContainer()` could be null and is dereferenced at line 356.
   
   ---
   
   <details><summary><b>ℹī¸ Learn about @sonatype-lift commands</b></summary>
   
   You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
   | **Command** | **Usage** |
   | ------------- | ------------- |
   | `@sonatype-lift ignore` | Leave out the above finding from this PR |
   | `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
   | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
   
   **Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
   <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
   
   
   
   ---
   
   Was this a good recommendation?
   [ [🙁 Not relevant](https://www.sonatype.com/lift-comment-rating?comment=349335606&lift_comment_rating=1) ] - [ [😕 Won't fix](https://www.sonatype.com/lift-comment-rating?comment=349335606&lift_comment_rating=2) ] - [ [😑 Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=349335606&lift_comment_rating=3) ] - [ [🙂 Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=349335606&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=349335606&lift_comment_rating=5) ]



-- 
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