Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Problem deleting IProject
Problem deleting IProject [message #500374] Wed, 25 November 2009 19:29 Go to next message
Brian Vosburgh is currently offline Brian Vosburgh
Messages: 132
Registered: July 2009
Senior Member
In our JUnit tests, we call IProject.delete(true, true, null) in tearDown().
Sporadically, this delete will fail with a CoreException with the message:

Problems encountered while deleting files.

From what I can tell, the problem occurs when deleting the src directory,
which, at that time, appears to be empty. Does anyone have any hints as to
how I can debug this exception and uncover exactly what the "problems" are?

Thanks.
Re: Problem deleting IProject [message #500382 is a reply to message #500374] Wed, 25 November 2009 20:27 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
If you are on a windows system and something has a file open in the src directory the OS will not permit the file (and thus directory) from being deleted. I had a problem on my windows system where an unrelated (and unwanted) piece of software was periodically polling all of the directories and really interfering with the operation of Eclipse.

There is also an intermittant problem in some versions of windows where the java delete does not work on the first try and works a bit later. I have a wrapper around delete that tried a few times (with a small wait between times) and that seems to deal with that issue.

If you are not on a windows system, then I'm not sure what this could mean.


Re: Problem deleting IProject [message #501081 is a reply to message #500382] Mon, 30 November 2009 22:41 Go to previous messageGo to next message
Walter Harley is currently offline Walter Harley
Messages: 847
Registered: July 2009
Senior Member
Francis Upton wrote:
> If you are on a windows system and something has a file open in the src
> directory the OS will not permit the file (and thus directory) from
> being deleted. I had a problem on my windows system where an unrelated
> (and unwanted) piece of software was periodically polling all of the
> directories and really interfering with the operation of Eclipse.
>
> There is also an intermittant problem in some versions of windows where
> the java delete does not work on the first try and works a bit later. I
> have a wrapper around delete that tried a few times (with a small wait
> between times) and that seems to deal with that issue.
>
> If you are not on a windows system, then I'm not sure what this could mean.

I believe Java Indexing is one example of a process that periodically locks
source files on a different thread. It seems that most people who write tests
like this run into this problem.

Since it's just a test, I'd suggest simply trying it a couple times in a loop
with a random wait of a second or two in between attempts - that is,

boolean success = delete(...);
int retries = 0;
while (!success and ++retries <= 5) {
wait for random time 0.5-1.5 secs
success = delete();
}

Might be all you need to reduce the rate of failure down to "good enough".
Re: Problem deleting IProject [message #501844 is a reply to message #501081] Fri, 04 December 2009 02:58 Go to previous message
Brian Vosburgh is currently offline Brian Vosburgh
Messages: 132
Registered: July 2009
Senior Member
Thanks. We've been using those workarounds off and on for a few years; but I
really wanted to get to the root of the problem. Oh well.

So, I had 2 related questions:

1. Why is there no more information about what actually caused the problem?
Which file/folder caused the exception? A vanilla "Problems encountered while
deleting files" isn't very helpful.

2. Why does this sort of thing not happen when I delete a Project from my
workspace using the UI? It does not appear the UI uses the same sort of
workaround (looping until the Project is actually deleted)? Has anyone ever had
problems manually deleting a Project?

Thanks.


Walter Harley wrote:
> Francis Upton wrote:
>> If you are on a windows system and something has a file open in the
>> src directory the OS will not permit the file (and thus directory)
>> from being deleted. I had a problem on my windows system where an
>> unrelated (and unwanted) piece of software was periodically polling
>> all of the directories and really interfering with the operation of
>> Eclipse.
>>
>> There is also an intermittant problem in some versions of windows
>> where the java delete does not work on the first try and works a bit
>> later. I have a wrapper around delete that tried a few times (with a
>> small wait between times) and that seems to deal with that issue.
>>
>> If you are not on a windows system, then I'm not sure what this could
>> mean.
>
> I believe Java Indexing is one example of a process that periodically
> locks source files on a different thread. It seems that most people who
> write tests like this run into this problem.
>
> Since it's just a test, I'd suggest simply trying it a couple times in a
> loop with a random wait of a second or two in between attempts - that is,
>
> boolean success = delete(...);
> int retries = 0;
> while (!success and ++retries <= 5) {
> wait for random time 0.5-1.5 secs
> success = delete();
> }
>
> Might be all you need to reduce the rate of failure down to "good enough".
Previous Topic:How to block second instance of Eclipse
Next Topic:Weird button behavior
Goto Forum:
  


Current Time: Tue Sep 30 12:02:56 GMT 2014

Powered by FUDForum. Page generated in 0.07458 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software