Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ private static final ParquetMetadata readFooter(

int FOOTER_LENGTH_SIZE = 4;
if (fileLen < MAGIC.length + FOOTER_LENGTH_SIZE + MAGIC.length) { // MAGIC + data + footer + footerIndex + MAGIC
throw new RuntimeException(filePath + " is not a Parquet file (length is too low: " + fileLen + ")");
throw new ParquetDecodingException(
filePath + " is not a Parquet file (length is too low: " + fileLen + ")");
}

// Read footer length and magic string - with a single seek
Expand All @@ -606,7 +607,7 @@ private static final ParquetMetadata readFooter(
f.seek(fileMetadataLengthIndex);
long readFileMetadataLength = readIntLittleEndian(f) & 0xFFFFFFFFL;
if (readFileMetadataLength > Integer.MAX_VALUE) {
throw new RuntimeException("footer is too large: " + readFileMetadataLength + "to be read");
throw new ParquetDecodingException("footer is too large: " + readFileMetadataLength + "to be read");
}
int fileMetadataLength = (int) readFileMetadataLength;

Expand All @@ -618,14 +619,15 @@ private static final ParquetMetadata readFooter(
} else if (Arrays.equals(EFMAGIC, magic)) {
encryptedFooterMode = true;
} else {
throw new RuntimeException(filePath + " is not a Parquet file. Expected magic number at tail, but found "
+ Arrays.toString(magic));
throw new ParquetDecodingException(filePath
+ " is not a Parquet file. Expected magic number at tail, but found " + Arrays.toString(magic));
}

long fileMetadataIndex = fileMetadataLengthIndex - fileMetadataLength;
LOG.debug("read footer length: {}, footer index: {}", fileMetadataLength, fileMetadataIndex);
if (fileMetadataIndex < magic.length || fileMetadataIndex >= fileMetadataLengthIndex) {
throw new RuntimeException("corrupted file: the footer index is not within the file: " + fileMetadataIndex);
throw new ParquetDecodingException(
"corrupted file: the footer index is not within the file: " + fileMetadataIndex);
}
f.seek(fileMetadataIndex);

Expand Down