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 98583 - [ddapi] possible race condition, unclosed file.
Summary: [ddapi] possible race condition, unclosed file.
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: EJB (show other bugs)
Version: 6.x
Hardware: Sun All
: P3 blocker (vote)
Assignee: Erno Mononen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-22 02:35 UTC by _ pcw
Modified: 2009-11-10 06:50 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 _ pcw 2007-03-22 02:35:41 UTC
I happened to be reading through DDProvider.java from package
org.netbeans.modules.j2ee.dd.api.ejb, specifically the method
getDDRoot(FileObject fo) (lines 112-138 as of this writing) and noticed some
peculiarities I think should be checked out.

1. the following fragment

        synchronized (ddMap) {
            ejbJarProxy = getFromCache(fo);
            if (ejbJarProxy != null) {
                return ejbJarProxy;
            }
        }
        
        fo.addFileChangeListener(new DDFileChangeListener());

        ejbJarProxy = DDUtils.createEjbJarProxy(fo.getInputStream());
        putToCache(fo, ejbJarProxy);

would appear to have a race condition wrt/ the replacement of the proxy in
ddMap, since the put happens after the sychronization lock is given up.

2. It doesn't appear that the InputStream retrieved from the FileObject is ever
closed.

Similar problems exist for the DDProvider for app clients
(org.netbeans.modules.j2ee.dd.api.client.DDProvider.java), application
(org.netbeans.modules.j2ee.dd.api.application.DDProvider.java), and web
(org.netbeans.modules.j2ee.dd.api.web.DDProvider.java).

Normally I'd file this as a P2, but since I can't prove any of these issues, I
left it at P3.
Comment 1 Martin Adamek 2007-03-22 07:22:58 UTC
Some comments for whoever will fix this:

> 1.
see also method getDDRoot0(DDProviderDataObject) and issue 68064

> 2.
I already ran into InputStream closing problem in issue 98316
Comment 2 Jiri Prox 2007-09-17 20:30:50 UTC
Obsolete milestone, please reevaluate
Comment 3 Erno Mononen 2007-10-09 12:43:36 UTC
The described problems still exist, should be doable for 6.0.
Comment 4 Erno Mononen 2007-10-10 15:23:29 UTC
Fixed in trunk. Note that the web dd provider was already fixed. After having a second look at the unclosed file 
problem, I think it is not an issue in this particular method - please see org.xml.sax.InputSource.

Checking in ejb/DDProvider.java;
/cvs/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/api/ejb/DDProvider.java,v  <--  DDProvider.java
new revision: 1.24; previous revision: 1.23
done
Checking in application/DDProvider.java;
/cvs/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/api/application/DDProvider.java,v  <--  DDProvider.java
new revision: 1.12; previous revision: 1.11
done
Checking in client/DDProvider.java;
/cvs/j2ee/ddapi/src/org/netbeans/modules/j2ee/dd/api/client/DDProvider.java,v  <--  DDProvider.java
new revision: 1.8; previous revision: 1.7
done