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