Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6190

maven-resolver-provider's DefaultArtifactDescriptorReader has mismatched constructor and initService methods

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.5.0-alpha-1, 3.5.0-beta-1
    • Fix Version/s: 3.5.0
    • Component/s: Dependencies
    • Labels:
      None

      Description

      In DefaultArtifactDescriptorReader.java, the constructor annotated with @Inject differs in the parameters it takes from its initService() method.

      This discrepancy means among other things that its versionRangeResolver field is never initialized when a DI container is doing injection.

      Here is the relevant code, starting at line 112, with a comment where the problem is:

          @Inject
          DefaultArtifactDescriptorReader( RemoteRepositoryManager remoteRepositoryManager, VersionResolver versionResolver,
                                           ArtifactResolver artifactResolver, ModelBuilder modelBuilder,
                                           RepositoryEventDispatcher repositoryEventDispatcher, LoggerFactory loggerFactory )
          {
              setRemoteRepositoryManager( remoteRepositoryManager );
              setVersionResolver( versionResolver );
              // XXX <-- Note: no versionRangeResolver
              setArtifactResolver( artifactResolver );
              setModelBuilder( modelBuilder );
              setLoggerFactory( loggerFactory );
              setRepositoryEventDispatcher( repositoryEventDispatcher );
          }
      
          public void initService( ServiceLocator locator )
          {
              setLoggerFactory( locator.getService( LoggerFactory.class ) );
              setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
              setVersionResolver( locator.getService( VersionResolver.class ) );
              setVersionRangeResolver( locator.getService( VersionRangeResolver.class ) );
              setArtifactResolver( locator.getService( ArtifactResolver.class ) );
              setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
              modelBuilder = locator.getService( ModelBuilder.class );
              if ( modelBuilder == null )
              {
                  setModelBuilder( new DefaultModelBuilderFactory().newInstance() );
              }
          }
      

        Activity

        Hide
        schulte77 Christian Schulte added a comment -

        The versionRangeResolver currently is only passed to the DefaultModelResolver. It will be used there in 3.5.0 so this fixes a potential NullPointerException. Thanks for reporting.

        Show
        schulte77 Christian Schulte added a comment - The versionRangeResolver currently is only passed to the DefaultModelResolver . It will be used there in 3.5.0 so this fixes a potential NullPointerException . Thanks for reporting.
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Jenkins build maven-3.x #1579 (See https://builds.apache.org/job/maven-3.x/1579/)
        MNG-6190 maven-resolver-provider's DefaultArtifactDescriptorReader has (schulte: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=27ab7503a7196a40b5ed1007181c82cdcf11e03c)

        • (edit) maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1579 (See https://builds.apache.org/job/maven-3.x/1579/ ) MNG-6190 maven-resolver-provider's DefaultArtifactDescriptorReader has (schulte: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=27ab7503a7196a40b5ed1007181c82cdcf11e03c ) (edit) maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java

          People

          • Assignee:
            schulte77 Christian Schulte
            Reporter:
            ljnelson Laird Nelson
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development