Browse Source

plug resource leak as suggested by Mike Phillips in BZ issue 66001

master
Stefan Bodewig 3 years ago
parent
commit
2989738c90
2 changed files with 18 additions and 10 deletions
  1. +9
    -5
      WHATSNEW
  2. +9
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java

+ 9
- 5
WHATSNEW View File

@@ -4,11 +4,11 @@ Changes from Ant 1.9.16 TO Ant 1.9.17
Changes that could break older environments:
--------------------------------------------

* <get> has a new attribute authenticateOnRedirect that can be used to
prevent Ant from sending the configured credentials when following a
redirect. It is false by default, which means builds that rely on
credentials being used on the redirected URI may break.
Github Pull Request #173
* <get> has a new attribute authenticateOnRedirect that can be used to
prevent Ant from sending the configured credentials when following a
redirect. It is false by default, which means builds that rely on
credentials being used on the redirected URI may break.
Github Pull Request #173

Fixed bugs:
-----------
@@ -18,6 +18,10 @@ Fixed bugs:
the shorter alias names.
Bugzilla Report 65539

* <scp> may leak connections when trying to preserve the las modified
timestamps of files transferred recursively from a server.
Bugzilla Report 66001

Other changes:
--------------



+ 9
- 5
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java View File

@@ -310,12 +310,16 @@ public class ScpFromMessage extends AbstractSshMessage {
private void setLastModified(final File localFile) throws JSchException {
SftpATTRS fileAttributes = null;
final ChannelSftp channel = openSftpChannel();
channel.connect();
try {
fileAttributes = channel.lstat(remoteDir(remoteFile)
+ localFile.getName());
} catch (final SftpException e) {
throw new JSchException("failed to stat remote file", e);
channel.connect();
try {
fileAttributes = channel.lstat(remoteDir(remoteFile)
+ localFile.getName());
} catch (final SftpException e) {
throw new JSchException("failed to stat remote file", e);
}
} finally {
channel.disconnect();
}
FileUtils.getFileUtils().setFileLastModified(localFile,
((long) fileAttributes


Loading…
Cancel
Save