diff options
author | Klaus Aehlig <aehlig@google.com> | 2018-06-08 07:23:34 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-08 07:24:36 -0700 |
commit | 30ef629d77b86a0effc47ad2a5c01e757951ecc6 (patch) | |
tree | aea2065005927246209d2c42592d922ddd1c803f /src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java | |
parent | 75641c9894656e1f3cf0320f227396a7123ce019 (diff) |
BlazeOptionHandler: only check in the parent directory, if there is one
When checking for a file called DO_NOT_BUILD_HERE in the parent direcotry of the
workspace path, first verify that there is such a parent directory. This avoids
a null pointer exception if the WORKSPACE file is in the top-level directory.
Fixes #5349
Change-Id: I81289a27a3f7fb0f4b5a112343de1b454fb5b8c5
PiperOrigin-RevId: 199790735
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java index 81a6f03f08..107cf4518d 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeOptionHandler.java @@ -144,17 +144,19 @@ public abstract class BlazeOptionHandler { return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; } - Path doNotBuild = - workspacePath.getParentDirectory().getRelative(BlazeWorkspace.DO_NOT_BUILD_FILE_NAME); - - if (doNotBuild.exists()) { - if (!commandAnnotation.canRunInOutputDirectory()) { - eventHandler.handle(Event.error(getNotInRealWorkspaceError(doNotBuild))); - return ExitCode.COMMAND_LINE_ERROR; - } else { - eventHandler.handle( - Event.warn( - runtime.getProductName() + " is run from output directory. This is unsound.")); + if (workspacePath.getParentDirectory() != null) { + Path doNotBuild = + workspacePath.getParentDirectory().getRelative(BlazeWorkspace.DO_NOT_BUILD_FILE_NAME); + + if (doNotBuild.exists()) { + if (!commandAnnotation.canRunInOutputDirectory()) { + eventHandler.handle(Event.error(getNotInRealWorkspaceError(doNotBuild))); + return ExitCode.COMMAND_LINE_ERROR; + } else { + eventHandler.handle( + Event.warn( + runtime.getProductName() + " is run from output directory. This is unsound.")); + } } } return ExitCode.SUCCESS; |