Have you verified that the suggested change fixes the problem?
 
xxxxxxxxxxxxxxxxxxxxxxxx
Scott Stark
Chief Technology Officer
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx
----- Original Message -----
Sent: Tuesday, July 16, 2002 10:00 AM
Subject: [JBoss-dev] RE: InputStream and JarFile are not closed in getManifest()

And this the reason why JBoss cannot delete the files after undeploy EAR files or SAR files.
 
Qingxian
-----Original Message-----
From: Qingxian Wang
Sent: 16 July 2002 17:55
To: '[EMAIL PROTECTED]'
Subject: InputStream and JarFile are not closed in getManifest()

The getManifest() method of DeploymentInfo class in org.jboss.deployment package does not close FileInputStream and JarFile after creating or getting a Manifest object.  This perhaps is the reason why JBoss cannot close JAR files when undeploying EAR or SAR files and therefore "Too many open files" problem is caused. 
 
The snipet of the JBoss (3.0.0) code is as follows:
 
/**
    * getManifest returns (if present) the deployment's manifest
    * it is lazy loaded to work from the localURL
    */
   public Manifest getManifest()
   {
      try
      {
         if (manifest == null)
         {
            File file = new File(localUrl.getFile());
           
            if (file.isDirectory())
               manifest= new Manifest(new FileInputStream(new File(file, "META-INF/MANIFEST.MF")));
           
            else // a jar
               manifest = new JarFile(file).getManifest();
        
         }
        
         return manifest;
      }
      // It is ok to barf at any time in the above, means no manifest
      catch (Exception ignored) { return null;}
   }
 
 
The suggested changes are as below:
 
public Manifest getManifest()
   {
      try
      {
         if (manifest == null)
         {
            File file = new File(localUrl.getFile());
           
            if (file.isDirectory()) {
                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(new File(file, "META-INF/MANIFEST.MF"));
                    manifest= new Manifest(fis);
                } finally {  // close the input stream
                    fis.close();
                }
            } else {// a jar
                JarFile jarFile = new JarFile(file);
                try {
                    manifest = jarFile.getManifest();
                } finally {  // close the JarFile
                    jarFile.close();
                }
            }        
         }
        
         return manifest;
      }
      // It is ok to barf at any time in the above, means no manifest
      catch (Exception ignored) { return null;}
   }
 
 
Regards
 
Qingxian Wang

Reply via email to