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:
parent
4bdb33cd8e
commit
61b5360d32
1 changed files with 32 additions and 25 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue