Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-23910

NullPointerException in JUnit tests calling postCredential

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • subversion-plugin
    • None
    • Jenkins 1.572 and lower

      Hi. This code:

      DescriptorExtensionList<SCM, SCMDescriptor<?>> desc = SubversionSCM.all();
      DescriptorImpl ss = (DescriptorImpl) desc.get(DescriptorImpl.class);
      StringWriter log = new StringWriter();
      PrintWriter logWriter = new PrintWriter(log);
      UserProvidedCredential upc =
      new UserProvidedCredential(user, password, null,
      request.findAncestorObject(AbstractProject.class));

      ss.postCredential(url[0], upc, logWriter);

      causes:

      Caused by: java.lang.NullPointerException
      at hudson.scm.SubversionSCM$DescriptorImpl$1.onSuccess(SubversionSCM.java:2249)
      at hudson.scm.UserProvidedCredential$AuthenticationManagerImpl.acknowledgeAuthentication(UserProvidedCredential.java:233)
      at org.tmatesoft.svn.core.auth.BasicAuthenticationManager.acknowledgeAuthentication(BasicAuthenticationManager.java:56)
      at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:749)
      at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:382)

      In:

      public void postCredential(String url, final UserProvidedCredential upc, PrintWriter logWriter) throws SVNException, IOException {
      SVNRepository repository = null;

      try {
      // the way it works with SVNKit is that
      // 1) svnkit calls AuthenticationManager asking for a credential.
      // this is when we can see the 'realm', which identifies the user domain.
      // 2) DefaultSVNAuthenticationManager returns the username and password we set below
      // 3) if the authentication is successful, svnkit calls back acknowledgeAuthentication
      // (so we store the password info here)
      repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
      repository.setTunnelProvider( createDefaultSVNOptions() );
      AuthenticationManagerImpl authManager = upc.new AuthenticationManagerImpl(logWriter) {
      @Override
      protected void onSuccess(String realm, Credential cred)

      { LOGGER.info("Persisted "+cred+" for "+realm); credentials.put(realm, cred); save(); if (upc.inContextOf!=null) new PerJobCredentialStore(upc.inContextOf).acknowledgeAuthentication(realm,cred); }

      };
      authManager.setAuthenticationForced(true);
      repository.setAuthenticationManager(authManager);
      repository.testConnection();
      authManager.checkIfProtocolCompleted();
      } finally

      { if (repository != null) repository.closeSession(); }

      }

      Because:
      credentials is null in "credentials.put(realm, cred);" statement.

      version 1.54 works fine

          [JENKINS-23910] NullPointerException in JUnit tests calling postCredential

          There are no comments yet on this issue.

            Unassigned Unassigned
            dmatag dmatag
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: