rahulgoswami commented on code in PR #14607:
URL: https://github.com/apache/lucene/pull/14607#discussion_r2471905670


##########
lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java:
##########
@@ -402,11 +389,38 @@ private static void parseSegmentInfos(
     }
 
     long totalDocs = 0;
+
     for (int seg = 0; seg < numSegments; seg++) {
       String segName = input.readString();
       byte[] segmentID = new byte[StringHelper.ID_LENGTH];
       input.readBytes(segmentID, 0, segmentID.length);
-      Codec codec = readCodec(input);
+      Codec codec = null;
+      try {
+        codec = readCodec(input);

Review Comment:
   Attempting to solve in the readCodec() private method as below. Reasonable?
   
   ```
    catch (IllegalArgumentException e) {
         for (String codecName : Codec.availableCodecs()) {
   
         // other backward codecs are present in the classpath
           // so if this was a supported index version, we should have found it 
in the class path too
           // aka this is likely an old index.
           if (<condition to detect whether codecName belongs to to 
org.apache.lucene.backward_codecs>) {
           
             throw new IndexTooOldException(message);
           }
         }
         if (name.startsWith("Lucene")) {
           throw new IllegalArgumentException(
               "Could not load codec '"
                   + name
                   + "'. Did you forget to add lucene-backward-codecs.jar?",
               e);
         }
         throw e;
       }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to