Source:
public void testCorruptedPage() throws IOException { Configuration conf = new Configuration(); conf.setBoolean(ParquetOutputFormat.PAGE_WRITE_CHECKSUM_ENABLED, true); Path path = writeSimpleParquetFile(conf, CompressionCodecName.UNCOMPRESSED); InputFile inputFile = HadoopInputFile.fromPath(path, conf); SeekableInputStream inputStream = inputFile.newStream(); int fileLen = (int) inputFile.getLength(); byte[] fileBytes = new byte[fileLen]; inputStream.readFully(fileBytes); inputStream.close(); fileBytes[fileLen / 8]++; fileBytes[fileLen / 8 + ((fileLen / 4) * 3)]++; OutputFile outputFile = HadoopOutputFile.fromPath(path, conf); PositionOutputStream outputStream = outputFile.createOrOverwrite(1024 * 1024); outputStream.write(fileBytes); outputStream.close(); conf.setBoolean(ParquetInputFormat.PAGE_VERIFY_CHECKSUM_ENABLED, false); try (ParquetFileReader reader = getParquetFileReader(path, conf, Arrays.asList(colADesc, colBDesc))) { PageReadStore pageReadStore = reader.readNextRowGroup(); DataPageV1 colAPage1 = readNextPage(colADesc, pageReadStore); assertFalse("Data in page was not corrupted", Arrays.equals(colAPage1.getBytes().toByteArray(), colAPage1Bytes)); readNextPage(colADesc, pageReadStore); readNextPage(colBDesc, pageReadStore); DataPageV1 colBPage2 = readNextPage(colBDesc, pageReadStore); assertFalse("Data in page was not corrupted", Arrays.equals(colBPage2.getBytes().toByteArray(), colBPage2Bytes)); } conf.setBoolean(ParquetInputFormat.PAGE_VERIFY_CHECKSUM_ENABLED, true); try (ParquetFileReader reader = getParquetFileReader(path, conf, Arrays.asList(colADesc, colBDesc))) { assertVerificationFailed(reader); } }

Target:
public void testCorruptedPage() throws IOException { Configuration conf = new Configuration(); conf.setBoolean(ParquetOutputFormat.PAGE_WRITE_CHECKSUM_ENABLED, true); Path path = writeSimpleParquetFile(conf, CompressionCodecName.UNCOMPRESSED); InputFile inputFile = HadoopInputFile.fromPath(path, conf); try (SeekableInputStream inputStream = inputFile.newStream()) { int fileLen = (int) inputFile.getLength(); byte[] fileBytes = new byte[fileLen]; inputStream.readFully(fileBytes); inputStream.close(); fileBytes[fileLen / 8]++; fileBytes[fileLen / 8 + ((fileLen / 4) * 3)]++; OutputFile outputFile = HadoopOutputFile.fromPath(path, conf); try (PositionOutputStream outputStream = outputFile.createOrOverwrite(1024 * 1024)) { outputStream.write(fileBytes); outputStream.close(); conf.setBoolean(ParquetInputFormat.PAGE_VERIFY_CHECKSUM_ENABLED, false); try (ParquetFileReader reader = getParquetFileReader(path, conf, Arrays.asList(colADesc, colBDesc))) { PageReadStore pageReadStore = reader.readNextRowGroup(); DataPageV1 colAPage1 = readNextPage(colADesc, pageReadStore); assertFalse("Data in page was not corrupted", Arrays.equals(colAPage1.getBytes().toByteArray(), colAPage1Bytes)); readNextPage(colADesc, pageReadStore); readNextPage(colBDesc, pageReadStore); DataPageV1 colBPage2 = readNextPage(colBDesc, pageReadStore); assertFalse("Data in page was not corrupted", Arrays.equals(colBPage2.getBytes().toByteArray(), colBPage2Bytes)); } conf.setBoolean(ParquetInputFormat.PAGE_VERIFY_CHECKSUM_ENABLED, true); try (ParquetFileReader reader = getParquetFileReader(path, conf, Arrays.asList(colADesc, colBDesc))) { assertVerificationFailed(reader); } } } }