Make HardlinkedExecRoot correctly mount empty directory inputs.

Fixes #2597

--
PiperOrigin-RevId: 148999160
MOS_MIGRATED_REVID=148999160
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/HardlinkedExecRoot.java b/src/main/java/com/google/devtools/build/lib/sandbox/HardlinkedExecRoot.java
index 5bf7c4f..ceace7a 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/HardlinkedExecRoot.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/HardlinkedExecRoot.java
@@ -149,6 +149,9 @@
       java.nio.file.Files.createLink(targetNio, sourceNio);
       // Directory
     } else if (source.isDirectory()) {
+      // Eagerly create target directory in case source is an empty directory.
+      FileSystemUtils.createDirectoryAndParents(target);
+
       Collection<Path> subpaths = source.getDirectoryEntries();
       for (Path sourceSubpath : subpaths) {
         Path targetSubpath = target.getRelative(sourceSubpath.relativeTo(source));