Hi.
I'm just getting started with Jersey, so I'll apologize upfront for my
newbieness :)
Anyway, I'm writing a resource class using streams as an entity type.
This is the whole of my GET method (for now):
@HttpMethod("GET")
@ProduceMime("application/xml")
public InputStream getXml() {
try {
return new BufferedInputStream(
new FileInputStream(
"C:\\temp\\docs\\xmlrepo\\net\\rafaelferreira\\jserverdoc\\sample\\ClasseA.xml"));
} catch (FileNotFoundException ex) {
throw new NotFoundException(ex.getMessage());
}
}
I noticed that glassfish was keeping a handle to the file after
invocation. Is this behaviour expected? In cases such as this, does the
user need to explicitly read from an origin stream into memory and then
return the buffer to the framework?
Poking around with the source code, I think that maybe
AbstractTypeEntityProvider.writeTo(InputStream in, OutputStream out)
could take care of closing the input stream, but I don't know if this
would interact badly with the rest of the code.
Thanks!
--
*Rafael de França Ferreira *
Sun Campus Ambassador at USP - Brazil
http://blogs.sun.com/rafaelferreira
http://www.rafaelferreira.net/