Uploaded image for project: 'Maven Wagon'
  1. Maven Wagon
  2. WAGON-285

Repository constructor NPE should be more verbose

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0
    • wagon-provider-api
    • None

    Description

      After having the following problem while trying to maven install my project, I suggest that the Repository constructor should be more verbose in case the "id" or "url" are null.

      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [ERROR] FATAL ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] id can not be null
      [INFO] ------------------------------------------------------------------------
      [INFO] Trace
      java.lang.NullPointerException: id can not be null
      	at org.apache.maven.wagon.repository.Repository.<init>(Repository.java:81)
      	at org.apache.maven.artifact.repository.DefaultArtifactRepository.<init>(DefaultArtifactRepository.java:70)
      	at org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory.createDeploymentArtifactRepository(DefaultArtifactRepositoryFactory.java:44)
      	at org.apache.maven.project.ProjectUtils.buildDeploymentArtifactRepository(ProjectUtils.java:80)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1029)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
      	at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
      	at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
      	at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
      	at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:560)
      	at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:560)
      	at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
      	at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
      	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      

      I haven't created a patch because I currently don't have the SVN plugin installed on my Eclipse (and I'm running out of time), but it should as simple as changing the Repository.java constructor to:

          public Repository( String id, String url )
          {
              if ( id == null )
              {
                  throw new NullPointerException( "id can not be null for Repository with url=" + url );
              }
              
              setId( id );
      
              if ( url == null )
              {
                  throw new NullPointerException( "url can not be null for Repository with id=" + id );
              }
              
              setUrl( url );
          }
      

      Attachments

        Activity

          People

            olamy Olivier Lamy
            nfrenay Nicolas Frenay
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: