From 8eac5b449ce230c8983a4058118859f6eedae316 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Fri, 6 Jul 2018 11:53:54 -0400 Subject: [PATCH] INT-4498: SFTP: Close privateKey resource JIRA: https://jira.spring.io/browse/INT-4498 Use `FileCopyUtils` instead of `StreamUtils`. **cherry-pick to 5.0.x, 4.3.x** --- .../integration/sftp/session/DefaultSftpSessionFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java index 0059330ca3..45458239e8 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java @@ -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. @@ -29,7 +29,7 @@ import org.springframework.core.io.Resource; 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; @@ -404,7 +404,7 @@ public class DefaultSftpSessionFactory implements SessionFactory, Share // 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());