[svn] IJPL-77600 Treat all "Unable to connect to a repository at URL" as connectivity problems

This should be more reliable than keeping an explicit list in `ServerUnavailableCallback` and handling all other problems in UsernamePasswordCallback, as in this case disruptive modal notification is shown


(cherry picked from commit 5f67deb80bb097b6889ef6d4387034c614222262)

IJ-MR-177790

GitOrigin-RevId: 2bc2cecf2a7ffea1d182ad56527a0513fe86a372
This commit is contained in:
Ilia.Shulgin
2025-09-17 12:02:52 +02:00
committed by intellij-monorepo-bot
parent 87ec3ef2d6
commit 0dae8dface
2 changed files with 17 additions and 23 deletions

View File

@@ -15,24 +15,21 @@ public final class ServerUnavailableCallback extends AuthCallbackCase {
// SVN 1.6 message
// SVN 1.7 message
// SVN 1.8-1.12 message: Unable to connect to a repository at URL +
// E73xxxx: various socket errors on Windows (e.g. E731001 - host not found; E730061 - connection refused)
// E12010x: The server unexpectedly closed the connection/improper response
// E67xxxx: socket errors on Unix (e.g. E670003 - DNS failure)
// E0000xx: socket errors on Mac (e.g. E000061 - connection refused)
// E0001xx: socket errors on Linux (e.g. E000111 - connection refused; E000113 - no route to host)
// SVN 1.8-1.12 message: Unable to connect to a repository at URL
private static final Pattern PATTERN = Pattern.compile(
"""
(?:svn: OPTIONS of '(.+)': ((?:Could not|could not).+)
? \\(.+\\)|svn: E175002: (.+)
svn: OPTIONS of '(.+)': ((?:Could not|could not).+)
? \\(.+\\)\
|svn: E175002: (.+)
svn: E175002: OPTIONS of '.+': (.+)(?:
.+)?|svn: E\\d{6}: (Unable to connect to a repository at URL .+)
svn: E(?:73\\d{4}|67\\d{4}|000[01]\\d{2}|12010\\d): (.+))"""
.+)?\
|svn: E\\d{6}: (Unable to connect to a repository at URL .+)
svn: E\\d+: (.+)"""
);
@Override
public boolean canHandle(String error) {
return PATTERN.matcher(error).matches();
return PATTERN.matcher(error).matches() && !UsernamePasswordCallback.isAuthenticationProblem(error);
}
@Override

View File

@@ -20,7 +20,6 @@ import java.util.regex.Pattern;
public class UsernamePasswordCallback extends AuthCallbackCase {
private static final @NonNls String COULD_NOT_AUTHENTICATE_TO_SERVER_MESSAGE = "could not authenticate to server";
private static final @NonNls String UNABLE_TO_CONNECT_MESSAGE = "Unable to connect to a repository";
private static final @NonNls String AUTHENTICATION_FAILED_MESSAGE = "Authentication failed";
private static final @NonNls String INVALID_CREDENTIALS_FOR_SVN_PROTOCOL = "svn: E170001: Can't get";
private static final @NonNls String PASSWORD_STRING = "password";
@@ -34,17 +33,15 @@ public class UsernamePasswordCallback extends AuthCallbackCase {
@Override
public boolean canHandle(String error) {
return
// http/https protocol invalid credentials
error.contains(AUTHENTICATION_FAILED_MESSAGE) ||
// svn protocol invalid credentials - messages could be "Can't get password", "Can't get username or password"
error.contains(INVALID_CREDENTIALS_FOR_SVN_PROTOCOL) && error.contains(PASSWORD_STRING) ||
// http/https protocol, svn 1.7, non-interactive
// we additionally check that error is not related to certificate verification - as CertificateCallbackCase could only handle
// untrusted but not invalid certificates
(error.contains(UNABLE_TO_CONNECT_MESSAGE) && !CertificateCallbackCase.isCertificateVerificationFailed(error)) ||
// http, svn 1.6, non-interactive
StringUtil.containsIgnoreCase(error, COULD_NOT_AUTHENTICATE_TO_SERVER_MESSAGE);
return isAuthenticationProblem(error);
}
public static boolean isAuthenticationProblem(String error) {
return error.contains(AUTHENTICATION_FAILED_MESSAGE) ||
// svn protocol invalid credentials - messages could be "Can't get password", "Can't get username or password"
error.contains(INVALID_CREDENTIALS_FOR_SVN_PROTOCOL) && error.contains(PASSWORD_STRING) ||
// http, svn 1.6, non-interactive
StringUtil.containsIgnoreCase(error, COULD_NOT_AUTHENTICATE_TO_SERVER_MESSAGE);
}
@Override