1 package fr.in2p3.jsaga.adaptor.data;
2
3 import org.globus.ftp.exception.FTPException;
4 import org.globus.io.streams.GridFTPOutputStream;
5 import org.ietf.jgss.GSSCredential;
6
7 import java.io.IOException;
8
9 /* ***************************************************
10 * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
11 * *** http://cc.in2p3.fr/ ***
12 * ***************************************************
13 * File: GsiftpOutputStream
14 * Author: Lionel Schwarz (lionel.schwarz@in2p3.fr)
15 * Date: 13 dec 2011
16 * ***************************************************
17 * Description: */
18 /**
19 * This class is used to catch the SocketException in IOException sent by close() when the socket is already closed
20 */
21 public class GsiftpOutputStream extends GridFTPOutputStream {
22
23 public GsiftpOutputStream(GSSCredential cred, GsiftpClient ftpClient,
24 String file, boolean append) throws IOException, FTPException {
25 super(cred, ftpClient.getAuthorization(), ftpClient.getHost(), ftpClient.getPort(), file, append, false);
26 }
27
28 /** override super.close() catch the exception at close() */
29 public void close() throws IOException {
30 try {
31 super.close();
32 } catch (IOException e) {
33 // when socket is already closed, ignore it
34 // use getMessage() because buggy getCause() returns null
35 if (e.getMessage()==null || !e.getMessage().toLowerCase().contains("socket closed")) {
36 throw e;
37 }
38 }
39 }
40 }