Skip to content

Commit 7f501fa

Browse files
committed
Remove usage of obsolete NestedIOException
Related to spring-projects/spring-framework#28198 Replaces its usage with the standard `IOException` which has supported a root cause since Java 6.
1 parent c1d29ab commit 7f501fa

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

spring-integration-core/src/main/java/org/springframework/integration/support/converter/AllowListDeserializingConverter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -26,7 +26,6 @@
2626

2727
import org.springframework.beans.DirectFieldAccessor;
2828
import org.springframework.core.ConfigurableObjectInputStream;
29-
import org.springframework.core.NestedIOException;
3029
import org.springframework.core.convert.converter.Converter;
3130
import org.springframework.core.serializer.DefaultDeserializer;
3231
import org.springframework.core.serializer.Deserializer;
@@ -117,7 +116,7 @@ public void setAllowedPatterns(String... allowedPatterns) {
117116
}
118117

119118
/**
120-
* Add package/class patterns to the allow list.
119+
* Add package/class patterns to the allowed list.
121120
* @param patterns the patterns to add.
122121
* @see #setAllowedPatterns(String...)
123122
*/
@@ -160,7 +159,7 @@ protected Class<?> resolveClass(ObjectStreamClass classDesc)
160159
return objectInputStream.readObject();
161160
}
162161
catch (ClassNotFoundException ex) {
163-
throw new NestedIOException("Failed to deserialize object type", ex);
162+
throw new IOException("Failed to deserialize object type", ex);
164163
}
165164
}
166165

spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/SftpSession.java

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -28,7 +28,6 @@
2828
import org.apache.commons.logging.Log;
2929
import org.apache.commons.logging.LogFactory;
3030

31-
import org.springframework.core.NestedIOException;
3231
import org.springframework.integration.file.remote.session.Session;
3332
import org.springframework.util.Assert;
3433
import 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

Comments
 (0)