11/*
2- * Copyright 2002-2020 the original author or authors.
2+ * Copyright 2002-2022 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2828import org .apache .commons .logging .Log ;
2929import org .apache .commons .logging .LogFactory ;
3030
31- import org .springframework .core .NestedIOException ;
3231import org .springframework .integration .file .remote .session .Session ;
3332import org .springframework .util .Assert ;
3433import org .springframework .util .FileCopyUtils ;
@@ -99,8 +98,8 @@ public boolean remove(String path) throws IOException {
9998 this .channel .rm (path );
10099 return true ;
101100 }
102- catch (SftpException e ) {
103- throw new NestedIOException ("Failed to remove file." , e );
101+ catch (SftpException ex ) {
102+ throw new IOException ("Failed to remove file." , ex );
104103 }
105104 }
106105
@@ -119,8 +118,8 @@ public LsEntry[] list(String path) throws IOException {
119118 return entries ;
120119 }
121120 }
122- catch (SftpException e ) {
123- throw new NestedIOException ("Failed to list files" , e );
121+ catch (SftpException ex ) {
122+ throw new IOException ("Failed to list files" , ex );
124123 }
125124 return new LsEntry [0 ];
126125 }
@@ -147,8 +146,8 @@ public void read(String source, OutputStream os) throws IOException {
147146 InputStream is = this .channel .get (source );
148147 FileCopyUtils .copy (is , os );
149148 }
150- catch (SftpException e ) {
151- throw new NestedIOException ("failed to read file " + source , e );
149+ catch (SftpException ex ) {
150+ throw new IOException ("failed to read file " + source , ex );
152151 }
153152 }
154153
@@ -157,8 +156,8 @@ public InputStream readRaw(String source) throws IOException {
157156 try {
158157 return this .channel .get (source );
159158 }
160- catch (SftpException e ) {
161- throw new NestedIOException ("failed to read file " + source , e );
159+ catch (SftpException ex ) {
160+ throw new IOException ("failed to read file " + source , ex );
162161 }
163162 }
164163
@@ -173,8 +172,8 @@ public void write(InputStream inputStream, String destination) throws IOExceptio
173172 try {
174173 this .channel .put (inputStream , destination );
175174 }
176- catch (SftpException e ) {
177- throw new NestedIOException ("failed to write file" , e );
175+ catch (SftpException ex ) {
176+ throw new IOException ("failed to write file" , ex );
178177 }
179178 }
180179
@@ -184,8 +183,8 @@ public void append(InputStream inputStream, String destination) throws IOExcepti
184183 try {
185184 this .channel .put (inputStream , destination , ChannelSftp .APPEND );
186185 }
187- catch (SftpException e ) {
188- throw new NestedIOException ("failed to write file" , e );
186+ catch (SftpException ex ) {
187+ throw new IOException ("failed to write file" , ex );
189188 }
190189 }
191190
@@ -227,19 +226,19 @@ public void rename(String pathFrom, String pathTo) throws IOException {
227226 }
228227 }
229228 catch (IOException ioex ) {
230- NestedIOException exception = new NestedIOException ("Failed to delete file " + pathTo , sftpex );
229+ IOException exception = new IOException ("Failed to delete file " + pathTo , sftpex );
231230 exception .addSuppressed (ioex );
232- throw exception ; // NOSONAR - added to suppressed exceptions
231+ throw exception ;
233232 }
234233 try {
235234 // attempt to rename again
236235 this .channel .rename (pathFrom , pathTo );
237236 }
238237 catch (SftpException sftpex2 ) {
239- NestedIOException exception =
240- new NestedIOException ("failed to rename from " + pathFrom + " to " + pathTo , sftpex );
238+ IOException exception =
239+ new IOException ("failed to rename from " + pathFrom + " to " + pathTo , sftpex );
241240 exception .addSuppressed (sftpex2 );
242- throw exception ; // NOSONAR - added to suppressed exceptions
241+ throw exception ;
243242 }
244243 }
245244 if (LOGGER .isDebugEnabled ()) {
@@ -254,7 +253,7 @@ public boolean mkdir(String remoteDirectory) throws IOException {
254253 }
255254 catch (SftpException ex ) {
256255 if (ex .id != ChannelSftp .SSH_FX_FAILURE || !exists (remoteDirectory )) {
257- throw new NestedIOException ("failed to create remote directory '" + remoteDirectory + "'." , ex );
256+ throw new IOException ("failed to create remote directory '" + remoteDirectory + "'." , ex );
258257 }
259258 }
260259 return true ;
@@ -265,8 +264,8 @@ public boolean rmdir(String remoteDirectory) throws IOException {
265264 try {
266265 this .channel .rmdir (remoteDirectory );
267266 }
268- catch (SftpException e ) {
269- throw new NestedIOException ("failed to remove remote directory '" + remoteDirectory + "'." , e );
267+ catch (SftpException ex ) {
268+ throw new IOException ("failed to remove remote directory '" + remoteDirectory + "'." , ex );
270269 }
271270 return true ;
272271 }
0 commit comments