Do not crash when attempting to upload a tree artifact.

These show up as directories. Filter these out and return null from the path converter, which should cause omission of those files from any build events.

RELNOTES: None
PiperOrigin-RevId: 208244910
diff --git a/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java b/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java
index 75b46c4..f45e3bc 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploaderTest.java
@@ -15,6 +15,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
 
 import com.google.bytestream.ByteStreamProto.WriteRequest;
 import com.google.bytestream.ByteStreamProto.WriteResponse;
@@ -162,6 +163,21 @@
   }
 
   @Test
+  public void testUploadDirectoryDoesNotCrash() throws Exception {
+    Path dir = fs.getPath("/dir");
+    dir.createDirectoryAndParents();
+    Map<Path, LocalFile> filesToUpload = new HashMap<>();
+    filesToUpload.put(dir, new LocalFile(dir, LocalFileType.OUTPUT));
+    ByteStreamUploader uploader = mock(ByteStreamUploader.class);
+    ByteStreamBuildEventArtifactUploader artifactUploader =
+        new ByteStreamBuildEventArtifactUploader(
+            uploader, "localhost", withEmptyMetadata, "instance");
+    PathConverter pathConverter = artifactUploader.upload(filesToUpload).get();
+    assertThat(pathConverter.apply(dir)).isNull();
+    artifactUploader.shutdown();
+  }
+
+  @Test
   public void someUploadsFail() throws Exception {
     // Test that if one of multiple file uploads fails, the upload future fails and that the
     // error is propagated correctly.