2 Replies Latest reply on Nov 20, 2008 4:08 AM by Ales Justin

    Multiple matching files by name in parsing deployer

    Ales Justin Master

      While doing webbeans mocking, I came up with the following issue.

      As current WarStructure adds all of WEB-INF/lib jars's META-INF
      as meta data location:

       archives = webinfLib.getChildren(webInfLibFilter);
       // Add the jars' META-INF for metadata
       for (VirtualFile jar : archives)
       {
       // either same as plain lib filter, null or accepts the jar
       if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
       metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
       }
      

      one could silently end up with wrong metadata.

      e.g. JPA PersistenceParsingDeployer::setName("persistence.xml")
      and then some lib jar accidentally has some persistence.xml leftover in its META-INF.
      There is a chance this is gonna be picked up,
      since we return on first found/matching file:
       protected VirtualFile searchMetaDataLocations(String name)
       {
       VirtualFile result = null;
       for(VirtualFile location : getMetaDataLocations())
       {
       try
       {
       result = location.getChild(name);
       if (result != null)
       {
       if (log.isTraceEnabled())
       log.trace("Found " + name + " in " + location.getName());
       deployed();
       break;
       }
       }
       catch (IOException e)
       {
       log.debug("Search exception invocation for metafile " + name + " in " + location.getName() + ", reason: " + e);
       }
       }
       return result;
       }
      


      What would be a proper way to handle this?
      This is current behavior when you call VFSDeploymentUnit::getMetaDataFile(String name).