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

[187096] Fix invalid use of Mutex

This commit is contained in:
Martin Oberhuber 2007-05-18 10:36:17 +00:00
parent 4892a31c45
commit b4d23ea0c6

View file

@ -464,7 +464,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
try
{
if (fileFilter == null)
{
fileFilter = "*"; //$NON-NLS-1$
@ -477,11 +478,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
filematcher = new NamePatternMatcher(fileFilter, true, true);
}
try
{
_ftpClient = getFTPClient();
if(!_ftpClient.changeWorkingDirectory(parentPath))
{
throw new RemoteFileIOException(new Exception(_ftpClient.getReplyString()));
@ -543,16 +540,12 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
FTPClient ftpClient = getFTPClient();
MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor);
try
{
MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor);
FTPClient ftpClient = getFTPClient();
ftpClient.changeWorkingDirectory(remoteParent);
setFileType(isBinary);
FileInputStream input = new FileInputStream(localFile);
@ -660,6 +653,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
IHostFile remoteHostFile = getFile(remoteParent,remoteFile,null);
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
try
{
FTPClient ftpClient = getFTPClient();
@ -668,12 +663,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
OutputStream output = null;
InputStream input = null;
try
{
ftpClient.changeWorkingDirectory(remoteParent);
setFileType(isBinary);
if (!localFile.exists())
{
File localParentFile = localFile.getParentFile();
@ -687,23 +678,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
output = new FileOutputStream(localFile);
input = ftpClient.retrieveFileStream(remoteFile);
}
catch (Exception e)
{
throw new RemoteFileIOException(e);
}
if(remoteHostFile != null && input != null)
{
progressMonitor.init(0, remoteFile, localFile.getName(), remoteHostFile.getSize());
byte[] buffer = new byte[4096];
int readCount;
try{
while((readCount = input.read(buffer)) > 0)
{
output.write(buffer, 0, readCount);
@ -723,17 +702,16 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
output.close();
ftpClient.completePendingCommand();
}catch(IOException e)
{
e.printStackTrace();
}
finally {
}
catch (Exception e)
{
throw new RemoteFileIOException(e);
} finally
{
_commandMutex.release();
}
}
}
return retValue;
}
@ -828,10 +806,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
FTPClient ftpClient = getFTPClient();
try {
FTPClient ftpClient = getFTPClient();
String source = remoteParent.endsWith(String.valueOf(getSeparator())) ? remoteParent + oldName : remoteParent + getSeparator() + oldName;
@ -872,10 +848,8 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
FTPClient ftpClient = getFTPClient();
try{
FTPClient ftpClient = getFTPClient();
String source = srcParent.endsWith(String.valueOf(getSeparator())) ? srcParent + srcName : srcParent + getSeparator() + srcName;
String target = tgtParent.endsWith(String.valueOf(getSeparator())) ? tgtParent + tgtName : tgtParent + getSeparator() + tgtName;
@ -904,10 +878,9 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
{
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE))
{
FTPClient ftpClient = getFTPClient();
try
{
FTPClient ftpClient = getFTPClient();
if(!ftpClient.changeWorkingDirectory(remoteParent))
{
throw new Exception(ftpClient.getReplyString()+" ("+remoteParent+")"); //$NON-NLS-1$ //$NON-NLS-2$