ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan \"Rambius\" Ivanov" <>
Subject Problem when running ivy in threads
Date Mon, 05 Nov 2007 21:32:56 GMT

I am using Ivy 1.4.1 on Windows XP SP2. I have developed some CruiseControl plugins similar
to ivycruise and I may contribute them to ivy in the future, but for now I have the following

My CruiseControl plugin checks the ivy repository if there is a new revision of a project's
dependencies since the last successful build and if there is a new CruiseControl build is
triggered. In order to check which are the project's dependencies, I parse (using Ivy API)
the project's ivy descriptor. So far so good, but I noticed that some of the ivy descriptors
get locked on Windows environment. After some debugging it turned out that the problem with
the locked files come from the fact that we run our cruisecontrol builds on multiple threads,
see [1].

I tried the reproduce the problem with some simple test case and I invented the following:


import fr.jayasoft.ivy.Ivy;
import fr.jayasoft.ivy.ModuleDescriptor;
import fr.jayasoft.ivy.parser.ModuleDescriptorParserRegistry;

public class Main {

    public static void main(String[] args) throws Exception {
        String ivyDescriptor = args[0]; // location of any ivy.xml
        Ivy ivy = new Ivy();

        ModuleDescriptorParserRegistry mdpr = ModuleDescriptorParserRegistry.getInstance();
        File ivyFile = new File(ivyDescriptor);        
        URL ivyFileURL = ivyFile.toURL();        
        ModuleDescriptor md = mdpr.parseDescriptor(ivy, ivyFileURL, true);
        System.out.println("module name is " + md.getModuleRevisionId().getName());
        Thread.sleep(60 * 1000);// sleep for one minute

After the line 

        ModuleDescriptor md = mdpr.parseDescriptor(ivy, ivyFileURL, true);

I would expect that all the streams opened to the ivyDescriptor file should be closed. However,
during the 1 minute thread sleep, I am not able, for example, to rename the file in Windows
Explorer, because it says it is being used by another program. After one minute I can rename
the file.

One my hypothesis is that the Ant API is not thread-safe. Is it true or not and can you give
me some advice on how to prevent ivy descriptors from being locked when I parse them with
the code above?



Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

View raw message