Achim Finke created KARAF-2943:
----------------------------------

             Summary: Wrong polymorphism leads to null variables
                 Key: KARAF-2943
                 URL: https://issues.apache.org/jira/browse/KARAF-2943
             Project: Karaf
          Issue Type: Bug
          Components: karaf-tooling
    Affects Versions: 3.0.1
            Reporter: Achim Finke
         Attachments: karaf.patch

As {{BundleRef}} and its parent {{ArtifactRef}} are defining the same variable 
{{artifact}} and the artifact resolver is resolving artifacts via 
{{ArtifactRef}} accessing the {{artifact}} via {{BundleRef}} returns null.

This bug is leading to an error using the following goal and configuration
{code}
<plugin>
  <groupId>org.apache.karaf.tooling</groupId>
  <artifactId>karaf-maven-plugin</artifactId>
  <version>3.0.1</version>
  <executions>
    <execution>
      ...
      <goals>
        <goal>features-export-meta-data</goal>
      </goals>
      <configuration>
        ...
        <mergedFeature>true</mergedFeature>
        <oneVersion>true</oneVersion>
      </configuration>
    </execution>
  </executions>
</plugin>
{code}
as maps for merging are being filled with null values instead of unique 
artifact attributes.

The root reason is unfortunately supressed see
{code:title=BundleRef.java|borderStyle=solid}
public void readManifest() {
    JarInputStream bundleJar = null;
    try {
        File file = artifact.getFile();
        bundleJar = new JarInputStream(new FileInputStream(file));
        Manifest manifest = bundleJar.getManifest();
        bundleSymbolicName = 
manifest.getMainAttributes().getValue("Bundle-SymbolicName");
        bundleVersion = manifest.getMainAttributes().getValue("Bundle-Version");
        bundleJar.close();
    } catch (Exception e) {
        // Ignore errors in manifest
    }
}
{code}

I attached a patch correcting the polymorphism but it seems to be a good idea 
to think about better error handling at this part.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to