1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +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
{
FTPClient ftpClient = new FTPClient();
boolean ok=false;
try {
ftpClient.connect(_ftpClient.getRemoteAddress());
ftpClient.login(_userId,_password);
@ -446,9 +446,16 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
} else {
ftpClient.setFileType(FTP.ASCII_FILE_TYPE);
}
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;
}