diff --git a/bag_unpacker/src/main/scala/weco/storage_service/bag_unpacker/storage/Unarchiver.scala b/bag_unpacker/src/main/scala/weco/storage_service/bag_unpacker/storage/Unarchiver.scala index 27d008087..3759adce8 100644 --- a/bag_unpacker/src/main/scala/weco/storage_service/bag_unpacker/storage/Unarchiver.scala +++ b/bag_unpacker/src/main/scala/weco/storage_service/bag_unpacker/storage/Unarchiver.scala @@ -1,18 +1,9 @@ package weco.storage_service.bag_unpacker.storage -import java.io.{BufferedInputStream, InputStream} -import org.apache.commons.compress.archivers.{ - ArchiveEntry, - ArchiveException, - ArchiveInputStream, - ArchiveStreamFactory -} -import org.apache.commons.compress.compressors.{ - CompressorException, - CompressorInputStream, - CompressorStreamFactory -} +import java.io.{BufferedInputStream, InputStream} +import org.apache.commons.compress.archivers.{ArchiveEntry, ArchiveException, ArchiveInputStream, ArchiveStreamFactory} +import org.apache.commons.compress.compressors.{CompressorException, CompressorInputStream, CompressorStreamFactory} import org.apache.commons.io.input.CloseShieldInputStream import scala.util.{Failure, Success, Try} @@ -51,7 +42,7 @@ object Unarchiver { } yield iterator private def createIterator( - archiveInputStream: ArchiveInputStream + archiveInputStream: ArchiveInputStream[ArchiveEntry] ): Iterator[(ArchiveEntry, InputStream)] = new Iterator[(ArchiveEntry, InputStream)] { private var latest: ArchiveEntry = _ @@ -92,12 +83,12 @@ object Unarchiver { private def extract( inputStream: InputStream - ): Either[UnarchiverError, ArchiveInputStream] = + ): Either[UnarchiverError, ArchiveInputStream[ArchiveEntry]] = Try { // We have to wrap in a BufferedInputStream because this method // only takes InputStreams that support the `mark()` method. new ArchiveStreamFactory() - .createArchiveInputStream(new BufferedInputStream(inputStream)) + .createArchiveInputStream(new BufferedInputStream(inputStream)).asInstanceOf[ArchiveInputStream[ArchiveEntry]] } match { case Success(stream) => Right(stream) case Failure(err: ArchiveException) => Left(ArchiveFormatError(err)) diff --git a/bag_unpacker/src/test/scala/weco/storage_service/bag_unpacker/fixtures/CompressFixture.scala b/bag_unpacker/src/test/scala/weco/storage_service/bag_unpacker/fixtures/CompressFixture.scala index fe83e74ae..9060d6ba1 100644 --- a/bag_unpacker/src/test/scala/weco/storage_service/bag_unpacker/fixtures/CompressFixture.scala +++ b/bag_unpacker/src/test/scala/weco/storage_service/bag_unpacker/fixtures/CompressFixture.scala @@ -182,7 +182,7 @@ trait CompressFixture[BagLocation <: Location, Namespace] compressorName: String )( outputStream: OutputStream - ): CompressorOutputStream = { + ): CompressorOutputStream[BufferedOutputStream] = { val compressorStreamFactory = new CompressorStreamFactory() @@ -195,13 +195,13 @@ trait CompressFixture[BagLocation <: Location, Namespace] compressorName, bufferedOutputStream ) - } + }.asInstanceOf[CompressorOutputStream[BufferedOutputStream]] private def packer( archiverName: String )( outputStream: OutputStream - ): ArchiveOutputStream = { + ): ArchiveOutputStream[ArchiveEntry] = { val archiveStreamFactory = new ArchiveStreamFactory()