diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java index 1d5ba9b08a435c..b770d5b4731aea 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexer.java @@ -103,7 +103,7 @@ public HttpStream connect( throw new InterruptedIOException(); } Function>> headerFunction = - getHeaderFunction(REQUEST_HEADERS, credentials); + getHeaderFunction(REQUEST_HEADERS, credentials, eventHandler); URLConnection connection = connector.connect(url, headerFunction); return httpStreamFactory.create( connection, @@ -125,7 +125,7 @@ public HttpStream connect( @VisibleForTesting static Function>> getHeaderFunction( - Map> baseHeaders, Credentials credentials) { + Map> baseHeaders, Credentials credentials, EventHandler eventHandler) { Preconditions.checkNotNull(baseHeaders); Preconditions.checkNotNull(credentials); @@ -137,6 +137,8 @@ static Function>> getHeaderFunction( // If we can't convert the URL to a URI (because it is syntactically malformed), or fetching // credentials fails for any other reason, still try to do the connection, not adding // authentication information as we cannot look it up. + eventHandler.handle( + Event.warn("Error retrieving auth headers, continuing without: " + e.getMessage())); } return ImmutableMap.copyOf(headers); }; diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java index 3ca3c8d443a79a..44a7aa863122f4 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/downloader/HttpConnectorMultiplexerTest.java @@ -165,7 +165,7 @@ public void testHeaderComputationFunction() throws Exception { Function>> headerFunction = HttpConnectorMultiplexer.getHeaderFunction( - baseHeaders, new StaticCredentials(additionalHeaders)); + baseHeaders, new StaticCredentials(additionalHeaders), eventHandler); // Unrelated URL assertThat(headerFunction.apply(new URL("http://example.org/some/path/file.txt"))) @@ -218,7 +218,7 @@ public void testHeaderComputationFunction() throws Exception { ImmutableMap.of("Authentication", ImmutableList.of("YW5vbnltb3VzOmZvb0BleGFtcGxlLm9yZw==")); Function>> combinedHeaders = HttpConnectorMultiplexer.getHeaderFunction( - annonAuth, new StaticCredentials(additionalHeaders)); + annonAuth, new StaticCredentials(additionalHeaders), eventHandler); assertThat(combinedHeaders.apply(new URL("http://hosting.example.com/user/foo/file.txt"))) .containsExactly("Authentication", ImmutableList.of("Zm9vOmZvb3NlY3JldA==")); assertThat(combinedHeaders.apply(new URL("http://unreleated.example.org/user/foo/file.txt")))