[jboss-jira] [JBoss JIRA] Created: (JBCL-43) PackageInformation retrieved from wrong jar

Stan Silvert (JIRA) jira-events at lists.jboss.org
Thu Sep 11 17:00:21 EDT 2008


PackageInformation retrieved from wrong jar
-------------------------------------------

                 Key: JBCL-43
                 URL: https://jira.jboss.org/jira/browse/JBCL-43
             Project: JBoss ClassLoader
          Issue Type: Bug
          Components: ClassLoaderPolicy, VFS
    Affects Versions: JBossCL.2.0.0.GA
            Reporter: Stan Silvert


I have an ear with these two files in the root:
jboss-seam.jar
jboss-seam-booking.jar

I want to get package info such as Implementation-Version from the class org.jboss.seam.Seam, which is in jboss-seam.jar.  However, Seam.class.getPackage().getImplementationVersion() returns the version from the manifest in jboss-seam-booking.jar.

I found that the problem is in VFSClassLoaderPolicy.  getPackageInformation() will call findRoot("org/jboss/seam").  But it happens to look in jboss-seam-booking.jar first.  So it finds classes with the package org.jboss.seam.booking and returns the package info from the wrong jar.

This change to VFSClassLoaderPolicy.findVirtualFileInfo() fixes the problem:

protected VirtualFileInfo findVirtualFileInfo(String path)
   {
      VirtualFileInfo result = vfsCache.get(path);
      if (result != null)
         return result;
      
      for (VirtualFile root : roots)
      {
         try
         {
            VirtualFile file = root.getChild(path);
            if (file != null)
            {
               // Must either be a file...
               if (file.isLeaf())
               {
                  result = new VirtualFileInfo(file, root);
                  vfsCache.put(path, result);
                  return result;
               }
               
               // ... or have a child that is a file
               for (VirtualFile child : file.getChildren())
               {
                  if (!child.isLeaf()) continue;
                  result = new VirtualFileInfo(file, root);
                  vfsCache.put(path, result);
                  return result;
               }
            }
         }
         catch (Exception ignored)
         {
         }
      }
      return null;
   }

I didn't want to commit this without someone else looking at it.  There are two concerns:
1) Searching all the children might have a performance impact?
2) Would this cause a problem for other code paths that use findVirtualFileInfo()?



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list