Remove obsolete org.springframework.core.NestedIOException
This commit removes Spring's custom NestedIOException and replaces its usage with the standard IOException which has supported a root cause since Java 6. Closes gh-28198
This commit is contained in:
parent
b570f60560
commit
2fb1dd177b
|
@ -54,7 +54,6 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|||
import org.springframework.beans.factory.support.BeanNameGenerator;
|
||||
import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase;
|
||||
import org.springframework.context.annotation.DeferredImportSelector.Group;
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
|
@ -690,7 +689,7 @@ class ConfigurationClassParser {
|
|||
return new SourceClass(ClassUtils.forName(className, this.resourceLoader.getClassLoader()));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new NestedIOException("Failed to load class [" + className + "]", ex);
|
||||
throw new IOException("Failed to load class [" + className + "]", ex);
|
||||
}
|
||||
}
|
||||
return new SourceClass(this.metadataReaderFactory.getMetadataReader(className));
|
||||
|
@ -1079,7 +1078,7 @@ class ConfigurationClassParser {
|
|||
catch (ClassNotFoundException ex) {
|
||||
// Ignore -> fall back to ASM next, except for core java types.
|
||||
if (className.startsWith("java")) {
|
||||
throw new NestedIOException("Failed to load class [" + className + "]", ex);
|
||||
throw new IOException("Failed to load class [" + className + "]", ex);
|
||||
}
|
||||
return new SourceClass(metadataReaderFactory.getMetadataReader(className));
|
||||
}
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subclass of {@link IOException} that properly handles a root cause,
|
||||
* exposing the root cause just like NestedChecked/RuntimeException does.
|
||||
*
|
||||
* <p>Proper root cause handling was added to the standard {@code IOException} in
|
||||
* Java 6, which is why Spring originally introduced {@code NestedIOException}
|
||||
* for compatibility with versions prior to Java 6.
|
||||
*
|
||||
* <p>The similarity between this class and the NestedChecked/RuntimeException
|
||||
* class is unavoidable, as this class needs to derive from IOException.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
* @see #getMessage
|
||||
* @see #printStackTrace
|
||||
* @see org.springframework.core.NestedCheckedException
|
||||
* @see org.springframework.core.NestedRuntimeException
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class NestedIOException extends IOException {
|
||||
|
||||
static {
|
||||
// Eagerly load the NestedExceptionUtils class to avoid classloader deadlock
|
||||
// issues on OSGi when calling getMessage(). Reported by Don Brown; SPR-5607.
|
||||
NestedExceptionUtils.class.getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a {@code NestedIOException} with the specified detail message.
|
||||
* @param msg the detail message
|
||||
*/
|
||||
public NestedIOException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a {@code NestedIOException} with the specified detail message
|
||||
* and nested exception.
|
||||
* @param msg the detail message
|
||||
* @param cause the nested exception
|
||||
*/
|
||||
public NestedIOException(@Nullable String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the detail message, including the message from the nested exception
|
||||
* if there is one.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -30,7 +30,6 @@ import java.util.function.Supplier;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
|
@ -120,7 +119,7 @@ public abstract class AbstractResource implements Resource {
|
|||
return ResourceUtils.toURI(url);
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
throw new NestedIOException("Invalid URI [" + url + "]", ex);
|
||||
throw new IOException("Invalid URI [" + url + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -22,7 +22,6 @@ import java.io.InputStream;
|
|||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class VfsResource extends AbstractResource {
|
|||
return VfsUtils.getURL(this.resource);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
|
||||
throw new IOException("Failed to obtain URL for file " + this.resource, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +85,7 @@ public class VfsResource extends AbstractResource {
|
|||
return VfsUtils.getURI(this.resource);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
|
||||
throw new IOException("Failed to obtain URI for " + this.resource, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -21,7 +21,6 @@ import java.io.InputStream;
|
|||
import java.io.ObjectInputStream;
|
||||
|
||||
import org.springframework.core.ConfigurableObjectInputStream;
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -72,7 +71,7 @@ public class DefaultDeserializer implements Deserializer<Object> {
|
|||
return objectInputStream.readObject();
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new NestedIOException("Failed to deserialize object type", ex);
|
||||
throw new IOException("Failed to deserialize object type", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.springframework.asm.ClassReader;
|
||||
import org.springframework.core.NestedIOException;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.ClassMetadata;
|
||||
|
@ -57,7 +56,7 @@ final class SimpleMetadataReader implements MetadataReader {
|
|||
return new ClassReader(is);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new NestedIOException("ASM ClassReader failed to parse class file - " +
|
||||
throw new IOException("ASM ClassReader failed to parse class file - " +
|
||||
"probably due to a new Java class file version that isn't supported yet: " + resource, ex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue