Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 417139

Summary: Server keeps file handle open after save
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ServerAssignee: Bogdan Gheorghe <gheorghe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gheorghe, Silenio_Quarti, Szymon.Brandys
Version: 3.0   
Target Milestone: 4.0 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2013-09-12 17:34:25 EDT
I am self-hosing by running a local Orion server. Launching it from the Eclipse IDE. 

Diff save is enabled (by default).

Recently I've hit a problem in which a file handle is left open. In Windows, this prevents you from doing anything else with the file (delete/rename/etc). 

E.g.:

1. I open "foo.js" in Orion, perform some edits, save.
2. From my Git command line, I decide to undo the changes -- run "git checkout foo.js"
4. Git complains that foo.js cannot be deleted
5. In Process Explorer, I see an open file handle from javaw.exe to "foo.js".

Note I didn't verify that the javaw process was actually the Orion server here.. So it could potentially be Eclipse misbehaving, not Orion.

I will update this bug when it happens again and check the process ID.
Comment 1 Mark Macdonald CLA 2013-09-12 17:51:51 EDT
(In reply to Mark Macdonald from comment #0)
> Note I didn't verify that the javaw process was actually the Orion server
> here.. So it could potentially be Eclipse misbehaving, not Orion.
> 
> I will update this bug when it happens again and check the process ID.

Yes, it is indeed the Orion server.
Comment 2 Bogdan Gheorghe CLA 2013-09-12 17:57:17 EDT
We were not closing the file reader after we read the file contents in memory. Let's leave this open for now so you can give it a try in a new build.
Comment 3 Bogdan Gheorghe CLA 2013-09-12 17:59:57 EDT
To clarify: I've released a change to master that closes the reader - let's leave the bug open, not the stream. ;)
Comment 5 John Arthorne CLA 2013-09-13 11:03:41 EDT
Stream should be closed in a finally block. We have a utility method for piping between streams and closing files at the end, so I switched to that. Also we don't need to wrap the streams in additional buffered reader/writer because we are already using a buffer and this will just allocate a duplicate buffer. Released this commit:

http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=829d6b2b5970bd358381515d9a161e68448b1b71
Comment 6 Szymon Brandys CLA 2013-11-05 08:54:05 EST
I was looking at old bugs. Is this one fixed?
Comment 7 Bogdan Gheorghe CLA 2013-11-05 10:47:50 EST
Yup - fixed. Closing...