TrueZIP
  1. TrueZIP
  2. TRUEZIP-301

Some JAR|WAR files in EAR are treated as file instead of directory when using TFile.isDirectory() function

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: TrueZIP 7.6.6
    • Fix Version/s: None
    • Component/s: TrueZIP Driver FILE
    • Labels:
      None
    • Environment:

      JDK1.6, windowsXP

      Description

      I used follow code to apply recursion to traverse the directory tree of one archive file.

      public static void main(String[] args)
      	{
      		String path = "D:\\AA7.2.0\\av.7.2.0\\av.biz\\deploy\\av-biz.ear";
      		TConfig.get().setArchiveDetector(
      			new TArchiveDetector(TArchiveDetector.NULL, new Object[][] {{"jar|ear|war",
      					new JarDriver(IOPoolLocator.SINGLETON)},}));
      		try
      		{
      			printName(new TFile(path));
      		}
      		catch (IOException e)
      		{
      			e.printStackTrace();
      		}
      		try
      		{
      			TVFS.umount();
      		}
      		catch (FsSyncException e)
      		{
      			// TODO Auto-generated catch block
      			e.printStackTrace();
      		}
      	}
      	
      	private static void printName(TFile file) throws IOException
      	{
      		if (file.isDirectory())
      		{
      			TFile[] children = file.listFiles();
      
      			for (TFile child : children)
      			{
      				printName(child);
      			}
      		}
      		else
      		{
      			print(file.getAbsolutePath());
      		}
      
      	}
      
      	private static void print(String filepath) throws IOException
      	{
      		if(filepath.endsWith("jar")||filepath.endsWith("war")||filepath.endsWith("ear"))
      		{
      			System.out.println(filepath);
      		}
      		
      		File file  = new File("D:/a.txt");
      		if(!file.exists())
      		{
      			file.createNewFile();
      		}
      		FileWriter writer = new FileWriter(file,true);
      		writer.write(filepath);
      		writer.write("\n");
      		writer.flush();
      		writer.close();
      		
      	}
      

      I found some JAR|WAR files in EAR was treated as file, isDirectory return false

        Activity

        Hide
        Christian Schlichtherle added a comment -

        First, you should wrap the creation of the TFile object into a TConfig.push()/pop() pair, otherwise you permanently change the configuration for the current thread.

        Second, I need the archive file which wasn't recognized. Can you attach it to this issue please?

        Show
        Christian Schlichtherle added a comment - First, you should wrap the creation of the TFile object into a TConfig.push()/pop() pair, otherwise you permanently change the configuration for the current thread. Second, I need the archive file which wasn't recognized. Can you attach it to this issue please?
        Hide
        Christian Schlichtherle added a comment -

        Forget my first note, I forgot that this is the main method, so you are effectively changing the global configuration and I suppose this is a wanted side effect.

        Show
        Christian Schlichtherle added a comment - Forget my first note, I forgot that this is the main method, so you are effectively changing the global configuration and I suppose this is a wanted side effect.
        Hide
        krase_tian added a comment -

        The file I operated is more than 70M, I delete some files in it in order to upload it.

        Show
        krase_tian added a comment - The file I operated is more than 70M, I delete some files in it in order to upload it.
        Hide
        Christian Schlichtherle added a comment -

        Thanks, I've downloaded the file. I suppose it contains business confidential information, so I deleted the attachment.

        Show
        Christian Schlichtherle added a comment - Thanks, I've downloaded the file. I suppose it contains business confidential information, so I deleted the attachment.
        Hide
        Christian Schlichtherle added a comment -

        I checked the EAR with a project generated from TrueZIP Archetype File* 7.6.6 and I could perfectly graph it's contents using the generated Tree class, so it works for me.

        To double check, could you please try to move the EAR to the current directory? Maybe the issue is only present when accessing an absolute path, although I have no reason to assume this.

        Show
        Christian Schlichtherle added a comment - I checked the EAR with a project generated from TrueZIP Archetype File* 7.6.6 and I could perfectly graph it's contents using the generated Tree class, so it works for me. To double check, could you please try to move the EAR to the current directory? Maybe the issue is only present when accessing an absolute path, although I have no reason to assume this.
        Hide
        Christian Schlichtherle added a comment -

        The submitter has asked me to close this issue on his behalf.

        Show
        Christian Schlichtherle added a comment - The submitter has asked me to close this issue on his behalf.

          People

          • Assignee:
            Christian Schlichtherle
            Reporter:
            krase_tian
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: