Merge branch 'master' into karthik/bazel0.4.4
diff --git a/.travis.yml b/.travis.yml
index d6f71c4..a288c2a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,9 +28,9 @@
   - nvm install stable
   - nvm use stable
   # download and install bazel
-  - wget -q 'https://github.com/bazelbuild/bazel/releases/download/0.3.1/bazel-0.3.1-installer-linux-x86_64.sh'
-  - chmod +x bazel-0.3.1-installer-linux-x86_64.sh
-  - ./bazel-0.3.1-installer-linux-x86_64.sh --user
+  - wget -q 'https://github.com/bazelbuild/bazel/releases/download/0.4.4/bazel-0.4.4-installer-linux-x86_64.sh'
+  - chmod +x bazel-0.4.4-installer-linux-x86_64.sh
+  - ./bazel-0.4.4-installer-linux-x86_64.sh --user
 
 before_script:
   # required for building the website docs
diff --git a/docker/Dockerfile.centos7 b/docker/Dockerfile.centos7
index 6628996..8daa235 100644
--- a/docker/Dockerfile.centos7
+++ b/docker/Dockerfile.centos7
@@ -2,7 +2,7 @@
 
 # This is passed to the heron build command via the --config flag
 ENV TARGET_PLATFORM centos
-ENV bazelVersion 0.2.3
+ENV bazelVersion 0.4.4
 ENV JAVA_VERSION 8u31
 ENV BUILD_VERSION b13
 
diff --git a/docker/Dockerfile.ubuntu14.04 b/docker/Dockerfile.ubuntu14.04
index fb2657e..ff8aab6 100644
--- a/docker/Dockerfile.ubuntu14.04
+++ b/docker/Dockerfile.ubuntu14.04
@@ -2,7 +2,7 @@
 
 # This is passed to the heron build command via the --config flag
 ENV TARGET_PLATFORM ubuntu
-ENV bazelVersion 0.2.3
+ENV bazelVersion 0.4.4
 
 RUN apt-get update && apt-get -y install \
       automake \
diff --git a/docker/Dockerfile.ubuntu15.10 b/docker/Dockerfile.ubuntu15.10
index bef6053..6c1c69c 100644
--- a/docker/Dockerfile.ubuntu15.10
+++ b/docker/Dockerfile.ubuntu15.10
@@ -2,7 +2,7 @@
 
 # This is passed to the heron build command via the --config flag
 ENV TARGET_PLATFORM ubuntu
-ENV bazelVersion 0.2.3
+ENV bazelVersion 0.4.4
 
 RUN apt-get update && apt-get -y install \
       automake \
diff --git a/docker/Dockerfile.ubuntu16.04 b/docker/Dockerfile.ubuntu16.04
index 374418a..44b0a3d 100644
--- a/docker/Dockerfile.ubuntu16.04
+++ b/docker/Dockerfile.ubuntu16.04
@@ -2,7 +2,7 @@
 
 # This is passed to the heron build command via the --config flag
 ENV TARGET_PLATFORM ubuntu
-ENV bazelVersion 0.2.3
+ENV bazelVersion 0.4.4
 
 RUN apt-get update && apt-get -y install \
       automake \
diff --git a/heron/metricsmgr/src/java/com/twitter/heron/metricsmgr/sink/WebSink.java b/heron/metricsmgr/src/java/com/twitter/heron/metricsmgr/sink/WebSink.java
index d81e9c3..a488a42 100644
--- a/heron/metricsmgr/src/java/com/twitter/heron/metricsmgr/sink/WebSink.java
+++ b/heron/metricsmgr/src/java/com/twitter/heron/metricsmgr/sink/WebSink.java
@@ -26,6 +26,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.stream.Stream;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
@@ -122,9 +123,8 @@
     int port = TypeUtils.getInteger(conf.getOrDefault(KEY_PORT, 0));
     if (port == 0) {
       if (!Strings.isNullOrEmpty(portFile)) {
-        try {
-          port = TypeUtils.getInteger(Files.lines(Paths.get(portFile)).findFirst()
-                  .get().trim());
+        try (Stream<String> lines = Files.lines(Paths.get(portFile))) {
+          port = TypeUtils.getInteger(lines.findFirst().get().trim());
         } catch (IOException | SecurityException | IllegalArgumentException e) {
           throw new IllegalArgumentException("Could not parse " + KEY_PORT_FILE + " " + portFile
                   + " Make sure the file is readable,"
diff --git a/heron/spi/src/java/com/twitter/heron/spi/common/Config.java b/heron/spi/src/java/com/twitter/heron/spi/common/Config.java
index 28f0d8d..9e66d1a 100644
--- a/heron/spi/src/java/com/twitter/heron/spi/common/Config.java
+++ b/heron/spi/src/java/com/twitter/heron/spi/common/Config.java
@@ -290,7 +290,7 @@
   }
 
   public boolean containsKey(Key key) {
-    return cfgMap.containsKey(key);
+    return cfgMap.containsKey(key.value());
   }
 
   public Set<String> getKeySet() {
diff --git a/tools/bazel.rc b/tools/bazel.rc
index 7d5f790..2518415 100644
--- a/tools/bazel.rc
+++ b/tools/bazel.rc
@@ -15,6 +15,9 @@
 
 # For Mac
 # To use it: bazel build --config=darwin
+build:darwin --ignore_unsupported_sandboxing
+build:darwin --genrule_strategy=standalone
+build:darwin --spawn_strategy=standalone
 build:darwin --python2_path /usr/bin/python2.7
 build:darwin --java_toolchain=//tools/java:heron_java_toolchain
 build:darwin --experimental_action_listener=tools/cpp:compile_cpp
diff --git a/tools/rules/jarjar_rules.bzl b/tools/rules/jarjar_rules.bzl
index 2cd04c1..6e2462a 100644
--- a/tools/rules/jarjar_rules.bzl
+++ b/tools/rules/jarjar_rules.bzl
@@ -46,6 +46,7 @@
             default = Label("//third_party/java/jarjar:jarjar_bin"),
             allow_files = True,
             executable = True,
+            cfg = "host",
         ),
     },
     outputs = {
diff --git a/tools/rules/pex_rules.bzl b/tools/rules/pex_rules.bzl
index 64899bf..89c196e 100644
--- a/tools/rules/pex_rules.bzl
+++ b/tools/rules/pex_rules.bzl
@@ -237,6 +237,7 @@
             default = Label("//third_party/pex:_pex"),
             allow_files = False,
             executable = True,
+            cfg = "host",
         ),
     },
 )
@@ -249,6 +250,7 @@
             default = Label("//third_party/pex:_pex"),
             allow_files = False,
             executable = True,
+            cfg = "host",
         ),
     },
     test = True,
diff --git a/tools/travis-ci/bazel.rc b/tools/travis-ci/bazel.rc
index d4b892e..bed86c8 100644
--- a/tools/travis-ci/bazel.rc
+++ b/tools/travis-ci/bazel.rc
@@ -24,7 +24,7 @@
 build --workspace_status_command scripts/release/status.sh
 
 # This is so we use a recent enough GCC when building.
-build --crosstool_top //tools/travis-ci/toolchain:CROSSTOOL
+# build --crosstool_top //tools/travis-ci/toolchain:CROSSTOOL
 
 # This is so we don't use sandboxed execution. Sandboxed execution
 # runs stuff in a container, and since Travis already runs its script