Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328943 - Writer is never closed when using URIConverter.Writeable
Summary: Writer is never closed when using URIConverter.Writeable
Status: RESOLVED WONTFIX
Alias: None
Product: EMF
Classification: Modeling
Component: XML/XMI (show other bugs)
Version: 2.6.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-28 11:50 EDT by Bryan Hunt CLA
Modified: 2010-10-28 17:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Hunt CLA 2010-10-28 11:50:20 EDT
I'm using a URIHandler to create an instance of URIConverter.Writable.  I'm supplying my own extension of Writer so that I can intercept the close() call in order to close a database connection.  The close() function is never called.

I've worked around the problem by calling close() when flush() is called.  This will get me by, but is very dangerous.

FYI, I do not see this problem when using URIConverter.Readable.  The close() function on the Reader is properly called.
Comment 1 Bryan Hunt CLA 2010-10-28 12:46:59 EDT
I found a better workaround by extending XMIResourceImpl and closing the writer in doSave().
Comment 2 Ed Merks CLA 2010-10-28 17:37:32 EDT
WritableOutputStream has

    public void close() throws IOException
    {
      super.close();
      writer.close();
    }
    
so I think the writer is closed when the stream is closed.

Note that when you call Resource.save(OutputStream, Map<Object, Object>) you created the stream and you're responsible for closing it.  Only when the Resource itself opens a stream does it close the stream.  After all, you may passing System.out and you'd not want that closed...

Or did I miss something?