Skip to content

Commit

Permalink
INT-4498: SFTP: Close privateKey resource
Browse files Browse the repository at this point in the history
JIRA: https://jira.spring.io/browse/INT-4498

Use `FileCopyUtils` instead of `StreamUtils`.

**cherry-pick to 5.0.x, 4.3.x**

(cherry picked from commit 8eac5b4)
  • Loading branch information
garyrussell authored and artembilan committed Jul 9, 2018
1 parent 3a13e59 commit 963a2fb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@
import org.springframework.integration.file.remote.session.SessionFactory;
import org.springframework.integration.file.remote.session.SharedSessionCapable;
import org.springframework.util.Assert;
import org.springframework.util.StreamUtils;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;

import com.jcraft.jsch.ChannelSftp.LsEntry;
Expand Down Expand Up @@ -404,7 +404,7 @@ private com.jcraft.jsch.Session initJschSession() throws Exception {

// private key
if (this.privateKey != null) {
byte[] keyByteArray = StreamUtils.copyToByteArray(this.privateKey.getInputStream());
byte[] keyByteArray = FileCopyUtils.copyToByteArray(this.privateKey.getInputStream());
String passphrase = this.userInfoWrapper.getPassphrase();
if (StringUtils.hasText(passphrase)) {
this.jsch.addIdentity(this.user, keyByteArray, null, passphrase.getBytes());
Expand Down

0 comments on commit 963a2fb

Please sign in to comment.