diff options
author | 2016-04-18 19:19:48 +0000 | |
---|---|---|
committer | 2016-04-19 09:46:39 +0000 | |
commit | af7e2404a94dee5538067dbba6dbf82334f91563 (patch) | |
tree | 878eaff622e9310318f10630007956c6f64408f7 /src/java_tools/buildjar/java/com | |
parent | 466ddd86d9282474d43218672e94890aaeff34ba (diff) |
Fixes GenClass exception when the temp directory does not exists.
--
Change-Id: Ie4236fbadc63ef38f08783acc0162cf0dd4fe872
Reviewed-on: https://bazel-review.googlesource.com/3422
MOS_MIGRATED_REVID=120146252
Diffstat (limited to 'src/java_tools/buildjar/java/com')
-rw-r--r-- | src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass.java index 7e6a5404ff..a0e053c107 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass/GenClass.java @@ -43,19 +43,25 @@ public class GenClass { * Recursively delete a directory. */ private static void deleteTree(Path directory) throws IOException { - Files.walkFileTree(directory, new SimpleFileVisitor<Path>() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } + if (directory.toFile().exists()) { + Files.walkFileTree( + directory, + new SimpleFileVisitor<Path>() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - }); + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) + throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } } public static void main(String[] args) throws IOException { |