Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpTimeoutException;
import javax.net.ssl.SSLException;
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void check(String url) {
}
} catch (UrlUnreachableException e) {
throw e;
} catch (UnknownHostException | ConnectException | HttpTimeoutException e) {
} catch (UnknownHostException | ConnectException | HttpTimeoutException | SSLException e) {
throw new UrlUnreachableException("URL_UNREACHABLE");
} catch (Exception e) {
log.warn("Reachability check failed for host {} — failing open: {}", URI.create(url).getHost(), e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.net.http.HttpHeaders;
import java.net.http.HttpResponse;
import java.net.http.HttpTimeoutException;
import javax.net.ssl.SSLException;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -105,6 +106,12 @@ void shouldRejectOnConnectionRefused() throws Exception {
assertThrows(UrlUnreachableException.class, () -> checker.check("https://example.com"));
}

@Test
void shouldRejectOnSslError() throws Exception {
doThrow(new SSLException("certificate unknown")).when(httpClient).send(any(), any());
assertThrows(UrlUnreachableException.class, () -> checker.check("https://example.com"));
}


@Test
void shouldFollowRedirectAndAcceptOn200() throws Exception {
Expand Down
Loading