smiroslav commented on code in PR #3292:
URL: https://github.com/apache/jackrabbit-oak/pull/3292#discussion_r4583816759


##########
oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tar/SegmentTarReader.java:
##########
@@ -138,16 +141,39 @@ public static Index loadAndValidateIndex(RandomAccessFile 
file, String name) thr
         return graph;
     }
 
+    /**
+     * The entry that follows the last segment tells whether the binary 
references are present:
+     * {@code <archive>.brf} if they are, {@code <archive>.gph} or {@code 
<archive>.idx} if they are
+     * missing. This tells a missing entry apart from a corrupt one, which 
still has its header.
+     */
     @Override
-    public @NotNull ByteBuffer getBinaryReferences() throws IOException {
+    public @Nullable ByteBuffer getBinaryReferences() throws IOException {
+        int position = endOfLastSegment();
+        ByteBuffer header = access.read(position, BLOCK_SIZE);
+        String entryName = readName(header);
+        if (entryName.equals(name + ".gph") || entryName.equals(name + 
".idx")) {
+            return null;
+        }
+        if (!entryName.equals(name + ".brf")) {
+            throw new IOException("Unexpected entry " + entryName + " after 
the last segment of " + name);
+        }
+        int end = position + BLOCK_SIZE + readSize(header);

Review Comment:
   Fixed. 



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

Reply via email to