summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamy Medhat <abdelaal@google.com>2020-06-13 17:43:19 -0400
committerRamy Medhat <abdelaal@google.com>2020-07-06 20:00:24 +0000
commit60f6c5a34ec9fde7916966eb26f11231377a2bc1 (patch)
tree8e941e93d11e3d2f4e15ae5d761bc702ae32fc28
parent841ad21b7e885be31fc63ef4abe4ba1d7931d7fb (diff)
Only report a violation when the file exists.
This CL fixes a bug discovered when turning on sandbox from frameworks/base metalava targets on RBE. The JVM tries to access the cache directory under $HOME/.cache, and if the directory doesn't exist (which is the case on RBE), the action still reports a violation. Bug: b/156613606 Test: ./gradlew. Also built entire topic with and without RBE_METALAVA. Change-Id: Ia694408004b2cac5e7106ec7a12b8ed68b4db6ba Merged-In: Ia694408004b2cac5e7106ec7a12b8ed68b4db6ba
-rw-r--r--src/main/java/com/android/tools/metalava/FileReadSandbox.kt5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/android/tools/metalava/FileReadSandbox.kt b/src/main/java/com/android/tools/metalava/FileReadSandbox.kt
index 02bbae2..a4ebb98 100644
--- a/src/main/java/com/android/tools/metalava/FileReadSandbox.kt
+++ b/src/main/java/com/android/tools/metalava/FileReadSandbox.kt
@@ -172,6 +172,9 @@ internal object FileReadSandbox {
}
fun isAccessAllowed(file: File): Boolean {
+ if (!file.exists()) {
+ return true
+ }
val absPath = file.absolutePath
if (allowedPaths.contains(absPath)) {
@@ -312,4 +315,4 @@ internal object FileReadSandbox {
override fun checkSetFactory() {
}
}
-} \ No newline at end of file
+}