…lines 1–233 unchanged (233 lines)
234 signatureLength = in.read(tarheader);
235 in.reset();
236 if (TarArchiveInputStream.matches(tarheader, signatureLength)) {
237 return new TarArchiveInputStream(in);
238 }
239 // COMPRESS-117 - improve auto-recognition
240 if (signatureLength >= 512) {
241 try {
242 TarArchiveInputStream tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));
243 tais.getNextEntry();
244 return new TarArchiveInputStream(in);
245 } catch (Exception e) { // NOPMD
246 // can generate IllegalArgumentException as well as IOException
247 // autodetection, simply not a TAR
248 // ignored
249 }
250 }
251 } catch (IOException e) {
252 throw new ArchiveException("Could not use reset and mark operations.", e);
253 }
254
255 throw new ArchiveException("No Archiver found for the stream signature");
256 }
257}
258