Forums » User questions »
Exception at closing streams
Added by Hajnal Akos over 11 years ago
Dear Developers,
Just a minor note - maybe applies to version 0.9.16 only.
If I close input/output streams opened by :
org.ogf.saga.file.FileInputStream fis = FileFactory.createFileInputStream(session, url); org.ogf.saga.file.FileOutputStream fos = FileFactory.createFileOutputStream(session, url, false);
using the parameterless close() method, sometimes I get exception (for different protocols, randomly):
java.io.IOException: java.io.EOFException at fr.in2p3.jsaga.impl.file.stream.FileInputStreamImpl.close(FileInputStreamImpl.java:68) ~[jsaga-engine-0.9.16-20130916.125217-22.jar:0.9.16-SNAPSHOT] java.io.IOException: java.io.EOFException at fr.in2p3.jsaga.impl.file.stream.FileOutputStreamImpl.close(FileOutputStreamImpl.java:80) ~[jsaga-engine-0.9.16-20130916.125217-22.jar:0.9.16-SNAPSHOT]
Regards,
Akos Hajnal
(PS. As a workaround, now I am trying to override close() with close(TaskMode.SYNC), but not too elegant...)
Replies (3)
RE: Exception at closing streams
-
Added by Schwarz Lionel over 11 years ago
Hi Akos,
The code hasn't changed in 0.9.17-SNAPSHOT.
Could you send me the full stacktrace on my email please?
Lionel
RE: Exception at closing streams
-
Added by Hajnal Akos over 11 years ago
Hi Lionel,
I tried in every possible way, on different protocols, with many threads, but couldn't reproduce the problem.
It seems that your code works fine, and I don't know now I could force jsaga to throw that exception...
Sorry for the false alarm,
Akos
RE: Exception at closing streams
-
Added by Schwarz Lionel over 11 years ago
Hi Akos,
From what I can see in the source code, this should happen with a particular (or few) protocol, because the exception is thrown by the method disconnect() implemented in the data adaptor (variable m_connection in the code below):
public void close() throws IOException { // close stream m_inStream.close(); // close connection if (m_connection != null) { try { m_connection.disconnect(); } catch (NoSuccessException e) { throw new IOException(e.getMessage()); } } }
So, you can simply catch IOException at close() and ignore it.
For the next release, I will maybe ignore exceptions thrown by disconnect().
Lionel