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 243447 - Incorrect project name displayed for new project
Summary: Incorrect project name displayed for new project
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0
Hardware: Macintosh (x86) Mac OS X
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-01 12:38 UTC by ionuion
Modified: 2014-04-04 01:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ionuion 2014-04-01 12:38:17 UTC
Environment:
Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Mac OS X version 10.9.2 running on x86_64; UTF-8; en_US (nb)

Steps to reproduce:
1. Create a new directory /tmp/projectholder
2. In NetBeans IDE create a new maven project (Categories:Maven, Projects:Java Application)
3. Fill in the following data, leave out the default for the rest:
  Project name: mavenproject1
  Project location: /tmp/projectholder
4. Rename project mavenproject1 (right click on project node, rename project, rename all fields: display name, artifactId, folder) to renamed
5. Create a new project (the exact same thing as steps 2. and 3.)

Expected result:
In the projects view the new project created at step 5. is displayed as mavenproject1

Actual result:
The project is displayed as renamed. Now you have two, could be confused about which is which.

Note
The pom.xml file contains the correct information information.
The tooltip shown when hovering the project node displays incorrect value for the ArtifactId
Comment 1 Milos Kleint 2014-04-02 09:53:50 UTC
the renamed project is first edited (artifactId/name is changed) and then moved to new location. The pom.xml save triggers a model reload and the file->model mapping is cached. Afterwards when creating the new project, the cached model is reused. Please note that a GC cycle would most likely remove the file->model mapping (it's weak referenced)

a Reload POM action fixes the problem.
Comment 2 Milos Kleint 2014-04-02 16:48:12 UTC
http://hg.netbeans.org/core-main/rev/57878a72f7d1

sort of fixes the issue by resetting the cached o.apache.maven.MavenProject instance that if bound to the old File instance. However please note that the netbeans' Project instances don't have a clearly defined lifecycle. Eg moving/renaming the project will expunge the old Project instance at the old location from project related data structures, but still some threads and parts of codebase can still have a reference to the old Project instance and ask it questions which in turn could end up loading the wrong MavenProject again before you create the new project at that location. Thus while the issue was deterministic initially, after the fix it turned indeterministic (mostly right)
Comment 3 Milos Kleint 2014-04-02 16:49:43 UTC
my general advice for deleting/moving/copying/renaming projects is: Don't do that, if you have it, restart the IDE afterwards. If it were up to me I would not support the operations on maven projects at all.
Comment 4 Quality Engineering 2014-04-04 01:59:13 UTC
Integrated into 'main-silver', will be available in build *201404040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/57878a72f7d1
User: Milos Kleint <mkleint@netbeans.org>
Log: #243447 clear maven project cache when renaming project.