} catch (UploadInterruptedException e) {
// Download interrupted by application code
- try {
- // still try to close output stream (e.g. file handle)
- out.close();
- } catch (IOException e1) {
- // NOP
- }
+ tryToCloseStream(out);
ReceivingFailedEvent event = new ReceivingFailedEventImpl(receiver,
filename, type, contentLength, totalBytes, e);
synchronized (application) {
// Note, we are not throwing interrupted exception forward as it is
// not a terminal level error like all other exception.
} catch (final Exception e) {
+ tryToCloseStream(out);
synchronized (application) {
ReceivingFailedEvent event = new ReceivingFailedEventImpl(
receiver, filename, type, contentLength, totalBytes, e);
}
}
+ private void tryToCloseStream(OutputStream out) {
+ try {
+ // try to close output stream (e.g. file handle)
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e1) {
+ // NOP
+ }
+ }
+
/**
* Removes any possible path information from the filename and returns the
* filename. Separators / and \\ are used.