Hello,
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 problem:
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 java.io.File;
import java.net.URL;
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?
Regards
Rambius
[1] http://cruisecontrol.sourceforge.net/main/configxml.html#threads
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com