]> source.dussan.org Git - jgit.git/commitdiff
Prevent NPE if no CredentialsProvider is registered 26/32626/1
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 1 Sep 2014 09:27:17 +0000 (11:27 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 1 Sep 2014 09:27:17 +0000 (11:27 +0200)
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>
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

index 514e11c2522960ef53812c571035e492b9689a24..45021e847cd3c60bcec2ea451c34413af1b5f575 100644 (file)
@@ -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}
index 5d9524bedab730e40b7a44648ffbc4fb0e7ff5dd..f2a1b948cccbecc9b6afbbb81abcc5acfd39ae4d 100644 (file)
@@ -398,6 +398,7 @@ public class JGitText extends TranslationBundle {
        /***/ public String newlineInQuotesNotAllowed;
        /***/ public String noApplyInDelete;
        /***/ public String noClosingBracket;
+       /***/ public String noCredentialsProvider;
        /***/ public String noHEADExistsAndNoExplicitStartingRevisionWasSpecified;
        /***/ public String noHMACsupport;
        /***/ public String noMergeBase;
index c4a6bd966edbd81515ae1708ed5e039e6d8031ee..06537905dba712ece7e9f0bf46414d298d01e930 100644 (file)
@@ -497,6 +497,9 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
                                                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