This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 138135 - LookupProvider.createAdditionalLookup() is called twice
Summary: LookupProvider.createAdditionalLookup() is called twice
Status: RESOLVED DUPLICATE of bug 134539
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks: 133860
  Show dependency tree
 
Reported: 2008-06-24 18:46 UTC by Milan Kuchtiak
Modified: 2008-06-26 08:42 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
StackTrace (10.15 KB, text/plain)
2008-06-24 18:53 UTC, Milan Kuchtiak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milan Kuchtiak 2008-06-24 18:46:58 UTC
Let's follow this scenario ;

1. create a Web Application project, e.g. WebApplication1
  (Since 6.0 - there is a lookup extensibility, and we register a specific LookupProvider in websvc/jaxwsmodel for Web
Project)
  The WebJaxWsLookupProvider.createAdditionalLookup() is called once - that's correct.
2. delete the project
3. create again Web Application project with the same name: WebApplication1
  The WebJaxWsLookupProvider.createAdditionalLookup() is called twice - this looks suspicious.

  Moreover, if FileOwnerQuery.getOwner() is called for some file object (from the project) - it may return the wrong
project instance.

We have some problems with that. See the issue 133860 (the last comment).
Comment 1 Milan Kuchtiak 2008-06-24 18:53:23 UTC
Created attachment 63358 [details]
StackTrace
Comment 2 Milan Kuchtiak 2008-06-24 18:56:15 UTC
I inserted the Thread.dumpStack() just at the beginning of
LookupProvider.createAdditionalLookup() method.

It's may be a general problem in Project's infrastructure.
Comment 3 David Konecny 2008-06-24 21:25:13 UTC
Deleting a project and recreating it under the same name is known to be problematic. Considering that in real life it is
something you rarely do it is not worth fixing. In your scenario there is probably still old instance of project in
memory which was not garbage collected yet - that's why it is called twice. 
Comment 4 Milan Kuchtiak 2008-06-25 07:41:32 UTC
I haven't invented this scenario intentionally. See the issue 133860.
The issue is common on DEMOs. That time you often create (and delete) projects of the same name. It happened also to me
at JavaOne Netbeans Booth, And you can see I am not the only person who hit this problem.

Please, rather, change the priority, or find why old project is not garbage collected properly.
You may look at the second stack trace - why this is ever called. This may be a generic problem of project infrastructure.
Comment 5 Milan Kuchtiak 2008-06-25 10:10:24 UTC
After some farther investigation, it doesn't look this is a garbage collection problem.
In the scenario described before (create project->delete project->create project with the same name) the
LookupProvider.createAdditionalLookup() method is called - twice - for entirely new project instances:

The recommended code is used here :
public class WebJaxWsLookupProvider implements LookupProvider {

    public Lookup createAdditionalLookup(Lookup baseContext) {
        Project prj = baseContext.lookup(Project.class);
        ...

The other ugly think (may be this is the consequence or not) is that FileOwnerQuery.getOwner(file) returns different
project instances when called for project's root and for file located in sources directory:

e.g.
FileOwnerQuery.getOwner(FileObject[/home/mkuchtiak/WebApplication1]) ... returns project instance A
FileOwnerQuery.getOwner(FileObject[/home/mkuchtiak/WebApplication1/src/java/a/A.java]) ... returns project instance B
 
This is the source of problem described in issue 133860.

BTW:
 it is not important whether new web service is created in project or not. The same happens with empty project.
 
Comment 6 David Konecny 2008-06-25 21:32:53 UTC
RE. "web project garbage collection" - I do not remember details; I know that GC played a role there for a while; it is
possible there are other issues.

This scenario is practised only in demos or testing. It is not how IDE is used by users in daily life. Therefore any
issues related are P3, P4. Issue 133860 should have been closed as WONTFIX or priority lowered or duplicate of this one.
Comment 7 Milos Kleint 2008-06-26 08:42:12 UTC
duplicate of #134539 milan and myself fixed yesterday.

*** This issue has been marked as a duplicate of 134539 ***