1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 10:25:32 +02:00

Fix exception handling for cloneFTPClient()

This commit is contained in:
Martin Oberhuber 2007-08-10 13:17:27 +00:00
parent 4bdb33cd8e
commit 61b5360d32

View file

@ -424,9 +424,9 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
*/ */
private FTPClient cloneFTPClient(boolean isBinary) throws IOException private FTPClient cloneFTPClient(boolean isBinary) throws IOException
{ {
FTPClient ftpClient = new FTPClient(); FTPClient ftpClient = new FTPClient();
boolean ok=false;
try {
ftpClient.connect(_ftpClient.getRemoteAddress()); ftpClient.connect(_ftpClient.getRemoteAddress());
ftpClient.login(_userId,_password); ftpClient.login(_userId,_password);
@ -446,9 +446,16 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
} else { } else {
ftpClient.setFileType(FTP.ASCII_FILE_TYPE); ftpClient.setFileType(FTP.ASCII_FILE_TYPE);
} }
ftpClient.registerSpyStream(_ftpLoggingOutputStream); ftpClient.registerSpyStream(_ftpLoggingOutputStream);
ok=true;
} finally {
//disconnect the erroneous ftpClient, but forward the exception
if (!ok) {
try {
ftpClient.disconnect();
} catch(Throwable t) { /*ignore*/ }
}
}
return ftpClient; return ftpClient;
} }