private static boolean isZip ( ArtifactEntry artifactEntry ) { if ( ! hasZipExtension ( artifactEntry . getName ( ) ) ) { return false ; } boolean validZip = false ; InputStream entryInputStream = null ; try { entryInputStream = artifactEntry . getInputStream ( ) ; if ( entryInputStream == null ) { return false ; } ZipInputStream zipInputStream = new ZipInputStream ( entryInputStream ) ; try { ZipEntry entry = zipInputStream . getNextEntry ( ) ; if ( entry == null ) { Tr . error ( tc , "bad.zip.data" , getPhysicalPath ( artifactEntry ) ) ; } else { validZip = true ; } } catch ( IOException e ) { String entryPath = getPhysicalPath ( artifactEntry ) ; Tr . error ( tc , "bad.zip.data" , entryPath ) ; } try { // attempt to close the zip, ignoring any error because we can't recover. zipInputStream . close ( ) ; } catch ( IOException ioe ) { // FFDC } } catch ( IOException e1 ) { // FFDC return false ; } return validZip ; }
Tell if an artifact entry is valid to be interpreted as a zip file container .