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 59615

Summary: AIOOBE from NewFile.preselectedProject when no projects open
Product: projects Reporter: Jesse Glick <jglick>
Component: Generic Projects UIAssignee: Jesse Glick <jglick>
Status: VERIFIED FIXED    
Severity: blocker CC: mkrauskopf
Priority: P2 Keywords: SIMPLEFIX
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Stack trace

Description Jesse Glick 2005-06-03 17:03:40 UTC
Dev build, Mustang. Start IDE. With no projects open, press Ctrl-N. Exception
thrown. Should rather do nothing, or beep, or something.
Comment 1 Jesse Glick 2005-06-03 17:04:07 UTC
Created attachment 22486 [details]
Stack trace
Comment 2 Martin Krauskopf 2005-07-20 14:53:57 UTC
*** Issue 61173 has been marked as a duplicate of this issue. ***
Comment 3 Jan Lahoda 2005-07-20 15:12:43 UTC
It seems to me that this was introduced in revision 1.19 of NewFile.java:
revision 1.19
date: 2005/05/17 00:15:43;  author: jglick;  state: Exp;  lines: +7 -2
Threading fix, avoids stack trace.

The problem is IMO following:
1. The user presses Ctrl-N, on an instance of NewFile action
"createContextAwareAction" method is called with appropriate Lookup (in the AWT
Thread probably).
2. New "NewFile" action is created (newly created actions have isEnabled() == true).
3. In the NewFile's constructor, "refresh" is called. The refresh replans to AWT
Thread to perform setEnabled and setDisplayName. (originaly, the setEnabled was
called synchronously in the refresh method).
4. isEnabled() is called on the newly created action (returns true as the
setEnabled(false) has not been runned yet), and as the result is true,
actionPerformed is called (resulting in the exception).

Please note that the action should be enabled only if
"OpenProjectList.getDefault().getOpenProjects().length > 0" and in such a case
calling OpenProjectList.getDefault().getOpenProjects()[0] seems OK.
Comment 4 Jesse Glick 2005-07-20 20:18:29 UTC
Yup, needed to change enablement synch if already in EQ.
Comment 5 Jesse Glick 2005-07-20 22:13:29 UTC
Checking in
projects/projectui/src/org/netbeans/modules/project/ui/actions/NewFile.java;
/cvs/projects/projectui/src/org/netbeans/modules/project/ui/actions/NewFile.java,v
 <--  NewFile.java
new revision: 1.20; previous revision: 1.19
done
Comment 6 Jaromir Uhrik 2006-01-16 15:45:48 UTC
Marking this issue as VERIFIED since the issue reporter == issue owner.