Merge "Make SeedFinder @Synchronized" into ub-jack
diff --git a/sched/src/com/android/sched/util/file/AbstractStreamFile.java b/sched/src/com/android/sched/util/file/AbstractStreamFile.java
index 93f9096..d9e508f 100644
--- a/sched/src/com/android/sched/util/file/AbstractStreamFile.java
+++ b/sched/src/com/android/sched/util/file/AbstractStreamFile.java
@@ -114,7 +114,7 @@
         return;
       }
     } catch (IOException e) {
-      throw new CannotCreateFileException(location);
+      throw new CannotCreateFileException(location, e);
     }
 
     throw new FileAlreadyExistsException(location);
diff --git a/sched/src/com/android/sched/util/file/CannotCreateFileException.java b/sched/src/com/android/sched/util/file/CannotCreateFileException.java
index 647e876..9fdc003 100644
--- a/sched/src/com/android/sched/util/file/CannotCreateFileException.java
+++ b/sched/src/com/android/sched/util/file/CannotCreateFileException.java
@@ -23,7 +23,7 @@
 import javax.annotation.Nonnull;
 
 /**
- * Exception when a file or directory can not be created.
+ * Exception when a file or directory cannot be created.
  */
 public class CannotCreateFileException extends SchedIOException {
   private static final long serialVersionUID = 1L;
@@ -48,6 +48,11 @@
 
   @Override
   protected String createMessage(@Nonnull String description) {
-    return description + " can not be created";
+    String message = description + " cannot be created";
+    Throwable cause = getCause();
+    if (cause != null) {
+      message += ": " + cause.getMessage();
+    }
+    return message;
   }
 }
diff --git a/sched/src/com/android/sched/vfs/CachedDirectFS.java b/sched/src/com/android/sched/vfs/CachedDirectFS.java
index 8a27c35..b163798 100644
--- a/sched/src/com/android/sched/vfs/CachedDirectFS.java
+++ b/sched/src/com/android/sched/vfs/CachedDirectFS.java
@@ -454,7 +454,7 @@
     return vFile;
 
     } catch (NotFileException e) {
-      throw new CannotCreateFileException(getVFileLocation(parent, name));
+      throw new CannotCreateFileException(getVFileLocation(parent, name), e);
     }
   }
 
@@ -482,7 +482,7 @@
       return vDir;
 
     } catch (NotDirectoryException e) {
-      throw new CannotCreateFileException(getVDirLocation(parent, name));
+      throw new CannotCreateFileException(getVDirLocation(parent, name), e);
     }
   }
 
diff --git a/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java b/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
index 01ff002..0a93ece 100644
--- a/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
+++ b/sched/src/com/android/sched/vfs/CaseInsensitiveFS.java
@@ -525,7 +525,7 @@
     try {
       return loadVDir(parent, name);
     } catch (NotDirectoryException e) {
-      throw new CannotCreateFileException(getVDirLocation(parent, name));
+      throw new CannotCreateFileException(getVDirLocation(parent, name), e);
     }
   }
 
@@ -547,7 +547,7 @@
         return original;
       }
     } catch (NotFileException e) {
-      throw new CannotCreateFileException(getVFileLocation(parent, name));
+      throw new CannotCreateFileException(getVFileLocation(parent, name), e);
     }
   }
 
diff --git a/sched/src/com/android/sched/vfs/InMemoryVDir.java b/sched/src/com/android/sched/vfs/InMemoryVDir.java
index f53e8b9..041728a 100644
--- a/sched/src/com/android/sched/vfs/InMemoryVDir.java
+++ b/sched/src/com/android/sched/vfs/InMemoryVDir.java
@@ -93,7 +93,7 @@
 
       return dir;
     } catch (NotDirectoryException e) {
-      throw new CannotCreateFileException(vfs.getVDirLocation(this, name));
+      throw new CannotCreateFileException(vfs.getVDirLocation(this, name), e);
     }
   }
 
@@ -109,7 +109,7 @@
 
       return file;
     } catch (NotFileException e) {
-      throw new CannotCreateFileException(vfs.getVFileLocation(this, name));
+      throw new CannotCreateFileException(vfs.getVFileLocation(this, name), e);
     }
   }