2424import java .util .ArrayList ;
2525import java .util .List ;
2626
27+ import org .apache .commons .compress .archivers .ArchiveException ;
2728import org .apache .commons .compress .archivers .ArchiveStreamFactory ;
2829import org .apache .commons .compress .archivers .zip .UnsupportedZipFeatureException ;
2930import org .apache .commons .compress .archivers .zip .ZipArchiveEntry ;
3031import org .apache .commons .compress .archivers .zip .ZipArchiveInputStream ;
3132import org .apache .commons .compress .archivers .zip .ZipFile ;
33+ import org .apache .commons .compress .compressors .CompressorException ;
3234import org .apache .commons .compress .compressors .CompressorStreamFactory ;
3335import org .apache .commons .io .IOUtils ;
3436import org .apache .commons .io .input .CloseShieldInputStream ;
@@ -119,9 +121,15 @@ static MediaType detectArchiveFormat(byte[] prefix, int length) {
119121 return TIFF ;
120122 }
121123 try {
122- String name = ArchiveStreamFactory .detect (
123- UnsynchronizedByteArrayInputStream .builder ().setByteArray (prefix ).setLength (length ).get ());
124+ String name = ArchiveStreamFactory .detect (UnsynchronizedByteArrayInputStream
125+ .builder ()
126+ .setByteArray (prefix )
127+ .setLength (length )
128+ .get ());
124129 return PackageConstants .getMediaType (name );
130+ } catch (ArchiveException e ) {
131+ //compress versions before 1.28.0 need this
132+ return MediaType .OCTET_STREAM ;
125133 } catch (IOException e ) {
126134 return MediaType .OCTET_STREAM ;
127135 }
@@ -133,6 +141,9 @@ static MediaType detectCompressorFormat(byte[] prefix, int length) {
133141 CompressorStreamFactory .detect (
134142 UnsynchronizedByteArrayInputStream .builder ().setByteArray (prefix ).setLength (length ).get ());
135143 return CompressorConstants .getMediaType (type );
144+ } catch (CompressorException e ) {
145+ //compress versions before 1.28.0 need this
146+ return MediaType .OCTET_STREAM ;
136147 } catch (IOException e ) {
137148 return MediaType .OCTET_STREAM ;
138149 }
0 commit comments