1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
import org .apache .commons .logging .Log ;
29
29
import org .apache .commons .logging .LogFactory ;
30
30
31
- import org .springframework .core .NestedIOException ;
32
31
import org .springframework .integration .file .remote .session .Session ;
33
32
import org .springframework .util .Assert ;
34
33
import org .springframework .util .FileCopyUtils ;
@@ -99,8 +98,8 @@ public boolean remove(String path) throws IOException {
99
98
this .channel .rm (path );
100
99
return true ;
101
100
}
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 );
104
103
}
105
104
}
106
105
@@ -119,8 +118,8 @@ public LsEntry[] list(String path) throws IOException {
119
118
return entries ;
120
119
}
121
120
}
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 );
124
123
}
125
124
return new LsEntry [0 ];
126
125
}
@@ -147,8 +146,8 @@ public void read(String source, OutputStream os) throws IOException {
147
146
InputStream is = this .channel .get (source );
148
147
FileCopyUtils .copy (is , os );
149
148
}
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 );
152
151
}
153
152
}
154
153
@@ -157,8 +156,8 @@ public InputStream readRaw(String source) throws IOException {
157
156
try {
158
157
return this .channel .get (source );
159
158
}
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 );
162
161
}
163
162
}
164
163
@@ -173,8 +172,8 @@ public void write(InputStream inputStream, String destination) throws IOExceptio
173
172
try {
174
173
this .channel .put (inputStream , destination );
175
174
}
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 );
178
177
}
179
178
}
180
179
@@ -184,8 +183,8 @@ public void append(InputStream inputStream, String destination) throws IOExcepti
184
183
try {
185
184
this .channel .put (inputStream , destination , ChannelSftp .APPEND );
186
185
}
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 );
189
188
}
190
189
}
191
190
@@ -227,19 +226,19 @@ public void rename(String pathFrom, String pathTo) throws IOException {
227
226
}
228
227
}
229
228
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 );
231
230
exception .addSuppressed (ioex );
232
- throw exception ; // NOSONAR - added to suppressed exceptions
231
+ throw exception ;
233
232
}
234
233
try {
235
234
// attempt to rename again
236
235
this .channel .rename (pathFrom , pathTo );
237
236
}
238
237
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 );
241
240
exception .addSuppressed (sftpex2 );
242
- throw exception ; // NOSONAR - added to suppressed exceptions
241
+ throw exception ;
243
242
}
244
243
}
245
244
if (LOGGER .isDebugEnabled ()) {
@@ -254,7 +253,7 @@ public boolean mkdir(String remoteDirectory) throws IOException {
254
253
}
255
254
catch (SftpException ex ) {
256
255
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 );
258
257
}
259
258
}
260
259
return true ;
@@ -265,8 +264,8 @@ public boolean rmdir(String remoteDirectory) throws IOException {
265
264
try {
266
265
this .channel .rmdir (remoteDirectory );
267
266
}
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 );
270
269
}
271
270
return true ;
272
271
}
0 commit comments