Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 242762

Summary: [common navigator] newly created project disappears in Project Explorer
Product: [Eclipse Project] JDT Reporter: Kaloyan Raev <kaloyan>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P2 CC: bokowski, daniel_megert, francisu, markus.kell.r, martinae
Version: 3.4Flags: daniel_megert: review+
Target Milestone: 3.4.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fix none

Description Kaloyan Raev CLA 2008-07-31 13:26:57 EDT
It looks like bug 208462 regressed in the official Ganymede release. 
I have been trying to catch it with the shortest possible steps to reproduce and I have a nice success today. 

1. Install the Eclipse for RCP developers.
2. Start Eclipse, choose workspace. 
3. Open the Resource perspective. 
4. Call the New Java project wizard. 
5. Enter 'a' for project name. 
6. Click the Next button. Project 'a' is created and appears in the Project Explorer view. OK
7. Click the Back button. The creation of project 'a' is reverted and disappears from the Project Explorer. OK
8. Click the Next button again. Project 'a' is created and appears in the Project Explorer, but shortly (less than a second) later disappears. PROBLEM

You may need repeat steps 6-7 one or more times, but at the end you will reproduce the problem.
Comment 1 Boris Bokowski CLA 2008-08-13 22:39:31 EDT
3.4.1 candidate? (if reproducible)
Comment 2 Francis Upton IV CLA 2008-08-13 23:18:50 EDT
I was also seeing new projects being created today in my testing and not appearing.  Then when I closed another project, the new project appeared.  This is certainly for 3.4.1, and I'm pretty sure I will be able to repro it.
Comment 3 Francis Upton IV CLA 2008-08-18 01:56:20 EDT
This might be related to or even caused by bug 244358 (double remove of a deleted project).

I was able to occasionally reproduce this using your instructions, and one thing I noticed in the tracing is that one of the remove() calls from the previous delete was being made after the project was added.  The remove calls are made asynchronously, though I'm not sure how they could get so far out of order.

I would be interested in any comments from the JDT folks.

I don't think this particular problem has anything to do with the fix to bug 208462.  There are many possible reasons for refresh problems; this appears different.

I'm going to continue to work on reproducing this and capturing stack trace information for the out of sequence remove() calls and hopefully that will tell us something.
Comment 4 Dani Megert CLA 2008-08-18 04:33:31 EDT
>This might be related to or even caused by bug 244358 (double remove of a
>deleted project).
Nope, double remove/add is unfortunately needed and in since day one of CN (R3.2), see other bug for details.

I suspect that the reason we see this now is the fix made for bug 184991. Adding Martin for comment.
Comment 5 Dani Megert CLA 2008-08-19 04:18:37 EDT
Francis, I cannot reproduce this on my machine. A test case (not manually but in the test plug-in) would be good. I have an improved fix for bug 184991 but I would need to know whether this really is the cause for this bug here. I could also give it to you to test if you want.
Comment 6 Francis Upton IV CLA 2008-08-19 10:24:15 EDT
(In reply to comment #5)
> A test case (not manually but in the test plug-in) would be good.
hehe, wouldn't we all love that.  Sadly, don't have one of those.  It was hard for  me to reproduce it on my machine manually, it happened according to the instructions quite rarely.  

 I have an improved fix for bug 184991 but I
> would need to know whether this really is the cause for this bug here. I could
> also give it to you to test if you want.
Yes, I would be interested in this. 

Comment 7 Dani Megert CLA 2008-08-19 10:29:53 EDT
>Yes, I would be interested in this. 
Today's I-build and HEAD (org.eclipse.jdt.ui) contains the fix.
Comment 8 Francis Upton IV CLA 2008-08-19 10:33:54 EDT
(In reply to comment #7)
> >Yes, I would be interested in this. 
> Today's I-build and HEAD (org.eclipse.jdt.ui) contains the fix.
> 
It's in PackageExplorerContentProvider?  I'm mainly interested in looking at it; not that I expect to get any better at reproducing this problem.

Comment 9 Dani Megert CLA 2008-08-19 10:46:11 EDT
>It's in PackageExplorerContentProvider?  I'm mainly interested in looking at
>it; not that I expect to get any better at reproducing this problem.
Yes. And I'm interested in whether it helps with that bug ;-)
Comment 10 Markus Keller CLA 2008-08-19 11:46:25 EDT
This problem can be reproduced (even on the first 'Next' click) when you
manually delay the update job in
PackageExplorerContentProvider.postAsyncUpdate(Display), e.g. by changing the
last line to
    fUpdateJob.schedule(10*1000);

The fix for bug 244514 does unfortunately not fix (nor otherwise affect) this
problem.
Comment 11 Markus Keller CLA 2008-08-19 13:35:59 EDT
The problem is in JavaNavigatorContentProvider.postAdd(Object, Object, Collection):
if (parent instanceof IJavaModel)
    super.postAdd(((IJavaModel) parent).getWorkspace(), element, runnables);

This is effectively a no-op, since the IWorkspace from getWorkspace() is not in the tree model. The fix is simply to add getRoot().

This code is called by PackageExplorerContentProvider.processDelta(..):

if (elementType == IJavaElement.JAVA_PROJECT) {
[..]
	// if added it could be that the corresponding IProject is already shown. Remove it first.
	// bug 184296
	if (kind == IJavaElementDelta.ADDED) { 
		postRemove(element.getResource(), runnables);
		postAdd(element.getParent(), element, runnables);
		return false;
	}
}

Since postAdd(..) always fails, the project is missing in the end, unless the asyncExec from ResourceExtensionContentProvider comes in later and adds the project again.
Comment 12 Markus Keller CLA 2008-08-19 13:37:18 EDT
Created attachment 110373 [details]
Fix
Comment 13 Markus Keller CLA 2008-08-19 13:39:57 EDT
Dani and/or Francis, please review the patch.
Comment 14 Dani Megert CLA 2008-08-20 04:11:12 EDT
Agree to fix for 3.4.1.
Comment 15 Markus Keller CLA 2008-08-20 04:36:51 EDT
Released to HEAD and R3_4_maintenance.
Comment 16 Dani Megert CLA 2008-08-28 05:49:49 EDT
Verified in M20080827-2000.
Comment 17 Kaloyan Raev CLA 2008-09-02 04:08:25 EDT
It seems to be fixed. Thanks!