Community
Participate
Working Groups
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.
I found a better workaround by extending XMIResourceImpl and closing the writer in doSave().
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?