Bug 244268 - [hotbug] GenericJpaFactory.contentType() not closing files
Summary: [hotbug] GenericJpaFactory.contentType() not closing files
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 2.0.1   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-14 23:54 EDT by John Pitman CLA
Modified: 2008-08-21 16:43 EDT (History)
5 users (show)

See Also:
david_williams: pmc_approved+
raghunathan.srinivasan: pmc_approved+
neil.hauge: pmc_approved? (naci.dai)
deboer: pmc_approved+
neil.hauge: pmc_approved+
neil.hauge: pmc_approved? (kaloyan)


Attachments
proposed patch - 2_0_maintenance stream (1.67 KB, patch)
2008-08-15 10:05 EDT, Karen Butzke CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Pitman CLA 2008-08-14 23:54:05 EDT
Build ID: WTP 3.0.1

The GenericJpaFactory.contentType(IFile file) method calls file.getContents(), but doesn't close the returned input stream.

While the FileInputStream's finalize method will eventually close the stream, until that happens the user (on Windows) will find any action that tries to move or delete the file will fail.

We would like a fix for this for 3.0.1.

[01172310]
Comment 1 Karen Butzke CLA 2008-08-15 10:05:13 EDT
Created attachment 110092 [details]
proposed patch - 2_0_maintenance stream

this patch handles closing the InputStream in the finally block
Comment 2 Neil Hauge CLA 2008-08-15 10:19:32 EDT
Please mark this as a hotbug request so we can make a case for 3.0.1.  Follow all of the steps in the doc. 

http://www.eclipse.org/webtools/adopters/hot_bug_process.html

I will accept it as a hotbug (although we may be past the cutoff for 3.0.1) and bring the bug to the PMC for review.  
Comment 3 John Pitman CLA 2008-08-15 11:58:36 EDT
Raising this as a hot bug

Affiliation: IBM
Release: WTP 3.0.1

The problem arises when the user first does something that causes Dali to evaluate a file' content type, and then the user tries to move or rename or delete the file before the GC has called finalizer to closed the stream.

We have seen this, for example, when generating DLL for the project, then renaming the generated DLL file. Renaming a file, then deciding you actually want to delete it is also particularly prone to running into the problem.  We have also seen it during refactoring, when renaming Java files.
Comment 4 David Williams CLA 2008-08-15 12:10:22 EDT
I think we might do one more 3.0.1 respin, and I'll be "half out" this afternoon, so will go ahead and mark with my PMC approval if the JPT team does agree to put this forward. 

Much thanks. 
Comment 5 Neil Hauge CLA 2008-08-15 12:48:14 EDT
This is a serious bug with a simple, low-risk fix.  See comment #3 for details.  I have reviewed the fix and approve it.

The bug has been tested with JUnits and manual testing.

Given that David has put his positive vote behind this bug, I will request the additional PMC approvals necessary to approve this for 3.0.1.

Comment 6 Karen Butzke CLA 2008-08-15 17:30:05 EDT
checked this change in to 2_0_maintenance and HEAD
Comment 7 Karen Butzke CLA 2008-08-18 08:26:57 EDT
released
Comment 8 Neil Hauge CLA 2008-08-21 16:43:14 EDT
John, have you had a chance to verify this fix?