Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-dev] Re: Scary code

John,

Yeap a bug :), I any case this business of Those were fixed, and that particular code is not needed anymore .  I will wait for a N or an I-Build to complete and release the changes.


There is something that makes me uneasy about the following code...

 core = StructureEdit.getStructureEditForRead(projects[i]);
....
some stufff
...
core.dispose();

This is very open to making mistakes (i.e unbalanced dispose). I do not have an answer to an alternative, try-finally is a clumsy workaround, but I have a feeling this bug will also be a pattern.


At 04:52 PM 4/5/2005, John Lanuti wrote:


Hey Naci,

See Michael's comments below...  The ModuleCore, now StructureEdit, needs to be released in a try finally block
whenever it is accessed.  I think he released the fix.

Thanks Michael,

John Lanuti
Software Engineer, IBM Rational
jlanuti@xxxxxxxxxx
t/l 441-7861

"I'll be awful sometimes, weakened to my knees, but I'll learn to get by on the little victories."  - Matt Nathanson



Michael Elder/Cambridge/IBM

04/05/2005 01:35 AM
To
John Lanuti/Raleigh/IBM@IBMUS
cc
Subject
Scary code





NewEjbWizard:


        protected IProject getDefaultEjbProject() {
                IProject project = null;
                IStructuredSelection selection = getCurrentSelection();
                if (selection != null && selection.getFirstElement() != null) {
                        project = ProjectUtilities.getProject(selection.getFirstElement());
                }
                if (project == null) {
                        IProject[] projects = ProjectUtilities.getAllProjects();
                        for (int i = 0; i < projects.length; i++) {
                                StructureEdit core = null;
                                core = StructureEdit.getStructureEditForRead(projects[i]);
                                WorkbenchComponent[] components = core.findComponentsByType(EJBArtifactEdit.TYPE_ID);
                                if (components != null && components.length > 0) {
                                        project = projects[i];
                                        // so if there are no components, the core is never disposed? MDE
                                        if (core != null)
                                                core.dispose();
                                        break;
                                }
                        }
                }
                return project;
        }



-------------------------------------------------------------------------
Kind Regards,

Michael D. Elder
Rational Studio / J2EE Tools Development    
IBM RTP Lab
Ext: (919) 543-8356
T/L:  441-8356
mdelder@xxxxxxxxxx


Naci Dai,
Managing Director

eteration a.s.
Inonu cad. Sumer sok. Zitas D1-15
Kozyatagi, Istanbul 81090
+90 (532) 573 7783 (cell)
+90 (216) 361 5434 (phone)
+90 (216) 361 2034 (fax)
http://www.eteration.com
mailto:nacidai@xxxxxxx
mailto:naci@xxxxxxxxxxxxx


Back to the top