@@ -585,14 +585,19 @@ private static final ParquetMetadata readFooter(
585585 }
586586
587587 // Read footer length and magic string - with a single seek
588- byte [] magic = new byte [MAGIC .length ];
589- long fileMetadataLengthIndex = fileLen - magic .length - FOOTER_LENGTH_SIZE ;
588+ long fileMetadataLengthIndex = fileLen - MAGIC .length - FOOTER_LENGTH_SIZE ;
590589 LOG .debug ("reading footer index at {}" , fileMetadataLengthIndex );
591590 f .seek (fileMetadataLengthIndex );
592- int fileMetadataLength = readIntLittleEndian (f );
593- f .readFully (magic );
591+ byte [] magicAndLengthBytes = new byte [FOOTER_LENGTH_SIZE + MAGIC .length ];
592+ f .readFully (magicAndLengthBytes );
593+ int fileMetadataLength = readIntLittleEndian (magicAndLengthBytes , 0 );
594594
595595 boolean encryptedFooterMode ;
596+ // using JDK >= 9: if (Arrays.equals(MAGIC, 0, MAGIC.length,
597+ // magicAndLengthBytes, FOOTER_LENGTH_SIZE, FOOTER_LENGTH_SIZE + MAGIC.length)) {
598+ // using JDK <= 8: need extract sub array then compare
599+ byte [] magic = new byte [MAGIC .length ];
600+ System .arraycopy (magicAndLengthBytes , FOOTER_LENGTH_SIZE , magic , 0 , MAGIC .length );
596601 if (Arrays .equals (MAGIC , magic )) {
597602 encryptedFooterMode = false ;
598603 } else if (Arrays .equals (EFMAGIC , magic )) {
0 commit comments