Prevent NPE if no CredentialsProvider is registered
If the git server requires authentication and no CredentialsProvider is registered TransportHttp.connect() would throw an NPE since it tries to reset the credentials provider. Instead throw a TransportException explaining the problem. Change-Id: Ib274e7d9c43bba301089975423de6a05ca5169f6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
46f3007b52
commit
3885ce2a94
|
@ -339,6 +339,7 @@ needsWorkdir=Needs workdir
|
|||
newlineInQuotesNotAllowed=Newline in quotes not allowed
|
||||
noApplyInDelete=No apply in delete
|
||||
noClosingBracket=No closing {0} found for {1} at index {2}.
|
||||
noCredentialsProvider=Authentication is required but no CredentialsProvider has been registered
|
||||
noHEADExistsAndNoExplicitStartingRevisionWasSpecified=No HEAD exists and no explicit starting revision was specified
|
||||
noHMACsupport=No {0} support: {1}
|
||||
noMergeBase=No merge base could be determined. Reason={0}. {1}
|
||||
|
|
|
@ -398,6 +398,7 @@ public static JGitText get() {
|
|||
/***/ public String newlineInQuotesNotAllowed;
|
||||
/***/ public String noApplyInDelete;
|
||||
/***/ public String noClosingBracket;
|
||||
/***/ public String noCredentialsProvider;
|
||||
/***/ public String noHEADExistsAndNoExplicitStartingRevisionWasSpecified;
|
||||
/***/ public String noHMACsupport;
|
||||
/***/ public String noMergeBase;
|
||||
|
|
|
@ -497,6 +497,9 @@ private HttpConnection connect(final String service)
|
|||
throw new TransportException(uri, MessageFormat.format(
|
||||
JGitText.get().authenticationNotSupported, uri));
|
||||
CredentialsProvider credentialsProvider = getCredentialsProvider();
|
||||
if (credentialsProvider == null)
|
||||
throw new TransportException(uri,
|
||||
JGitText.get().noCredentialsProvider);
|
||||
if (authAttempts > 1)
|
||||
credentialsProvider.reset(uri);
|
||||
if (3 < authAttempts
|
||||
|
|
Loading…
Reference in New Issue