From ef9e88a115979c43238e79ca6456502de55d6c4a Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 1 Oct 2014 08:04:39 -0400 Subject: [PATCH 1/2] Fix regression where IOExceptions were not caught on trying to access disk. Fixes #1632 --- ivy/src/main/scala/sbt/Resolver.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ivy/src/main/scala/sbt/Resolver.scala b/ivy/src/main/scala/sbt/Resolver.scala index 01db05ea1..7f558181d 100644 --- a/ivy/src/main/scala/sbt/Resolver.scala +++ b/ivy/src/main/scala/sbt/Resolver.scala @@ -3,7 +3,7 @@ */ package sbt -import java.io.File +import java.io.{ IOException, File } import java.net.URL import scala.xml.{ Text, NodeSeq, Elem, XML } import org.apache.ivy.plugins.resolver.DependencyResolver @@ -312,6 +312,8 @@ object Resolver { } catch { // Occurs inside File constructor when property or environment variable does not exist case _: NullPointerException => None + // Occurs when File does not exist + case _: IOException => None case e: SAXParseException => System.err.println(s"WARNING: Problem parsing ${f().getAbsolutePath}, ${e.getMessage}"); None } loadHomeFromSettings(() => new File(Path.userHome, ".m2/settings.xml")) orElse From 2b3f34f6f62d0fcef8dfc6dbab825d90bb01102c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 1 Oct 2014 08:18:09 -0400 Subject: [PATCH 2/2] Add file existence check for Eugene. --- ivy/src/main/scala/sbt/Resolver.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ivy/src/main/scala/sbt/Resolver.scala b/ivy/src/main/scala/sbt/Resolver.scala index 7f558181d..57a73dec2 100644 --- a/ivy/src/main/scala/sbt/Resolver.scala +++ b/ivy/src/main/scala/sbt/Resolver.scala @@ -304,11 +304,12 @@ object Resolver { private[this] def mavenLocalDir: File = { def loadHomeFromSettings(f: () => File): Option[File] = try { - val file = XML.loadFile(f()) - (file \ "localRepository").text match { + val file = f() + if(!file.exists) None + else ((XML.loadFile(file) \ "localRepository").text match { case "" => None case e @ _ => Some(new File(e)) - } + }) } catch { // Occurs inside File constructor when property or environment variable does not exist case _: NullPointerException => None