Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-10787

BundleEntryHandler.extractArtifactId prone to IllegalArgumentException

    XMLWordPrintableJSON

Details

    Description

      trying to address sonar findings for BundleEntryHandler (see SLING-10784) i noticed that there is no guarantee that 'artifactId' and 'version' are not left null after all the processing completed. if any of the two is null constructing a new ArtifactId object from the given strings will fail will IllegalArgumentException.

      it might be as simple as extracting the following statements out of the previous block that handles the groupId == null case:

      if (artifactId == null || artifactId.isEmpty()) {
                  artifactId = groupId;
      }
              
              if (version == null) {
                  Version osgiVersion = Version.parseVersion(getCheckedProperty(jarFile.getManifest(), Constants.BUNDLE_VERSION));
                  version = osgiVersion.getMajor() + "." + osgiVersion.getMinor() + "." + osgiVersion.getMicro() + (osgiVersion.getQualifier().isEmpty() ? "" : "-" + osgiVersion.getQualifier());
              }
      

      but i am not totally sure.... there is a reason the method BundleEntryHandler.extractArtifactId gets called out by sonar

      note: on line 472 of the same method IllegalArgumentException is caught.... so i assume the code doesn't expect this method to fail upon building the ArtifactId.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              angela Angela Schreiber
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: