mirror of
https://github.com/sbt/sbt.git
synced 2026-08-30 09:50:02 +02:00
Clean-up helper method to fully read InputStream
This commit is contained in:
@@ -82,7 +82,7 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
|
||||
|
||||
val bootstrapJar =
|
||||
Option(Thread.currentThread().getContextClassLoader.getResourceAsStream("bootstrap.jar")) match {
|
||||
case Some(is) => Cache.readFullySync(is)
|
||||
case Some(is) => FileUtil.readFully(is)
|
||||
case None =>
|
||||
Console.err.println(s"Error: bootstrap JAR not found")
|
||||
sys.exit(1)
|
||||
@@ -165,7 +165,7 @@ object Bootstrap extends CaseApp[BootstrapOptions] {
|
||||
entry.setTime(f.lastModified())
|
||||
|
||||
outputZip.putNextEntry(entry)
|
||||
outputZip.write(Cache.readFullySync(new FileInputStream(f)))
|
||||
outputZip.write(FileUtil.readFully(new FileInputStream(f)))
|
||||
outputZip.closeEntry()
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ object Scaladex {
|
||||
|
||||
val b = try {
|
||||
conn = new java.net.URL(url).openConnection().asInstanceOf[HttpURLConnection]
|
||||
coursier.Platform.readFullySync(conn.getInputStream)
|
||||
coursier.internal.FileUtil.readFully(conn.getInputStream)
|
||||
} finally {
|
||||
if (conn != null)
|
||||
coursier.Cache.closeConn(conn)
|
||||
|
||||
@@ -2,8 +2,6 @@ package coursier.cli.util
|
||||
|
||||
import java.util.zip.{ZipEntry, ZipInputStream}
|
||||
|
||||
import coursier.Platform
|
||||
|
||||
object Zip {
|
||||
|
||||
def zipEntries(zipStream: ZipInputStream): Iterator[(ZipEntry, Array[Byte])] =
|
||||
@@ -17,7 +15,7 @@ object Zip {
|
||||
def hasNext = nextEntry.nonEmpty
|
||||
def next() = {
|
||||
val ent = nextEntry.get
|
||||
val data = Platform.readFullySync(zipStream)
|
||||
val data = coursier.internal.FileUtil.readFully(zipStream)
|
||||
|
||||
update()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class CliBootstrapIntegrationTest extends FlatSpec with CliTestLib {
|
||||
if (e == null)
|
||||
throw new NoSuchElementException(s"Entry $path in zip file")
|
||||
else if (e.getName == path)
|
||||
coursier.Platform.readFullySync(zis)
|
||||
coursier.internal.FileUtil.readFully(zis)
|
||||
else
|
||||
zipEntryContent(zis, path)
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class CliBootstrapIntegrationTest extends FlatSpec with CliTestLib {
|
||||
|
||||
val content = try {
|
||||
fis = new FileInputStream(bootstrapFile)
|
||||
coursier.Platform.readFullySync(fis)
|
||||
coursier.internal.FileUtil.readFully(fis)
|
||||
} finally {
|
||||
if (fis != null) fis.close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user