Replace deep exception message nesting with custom inclusion of cause messages

Includes deprecation of NestedServletException, whereas NestedCheckedException and NestedRuntimeException remain as base classes with several convenience methods.

Closes gh-25162
This commit is contained in:
Juergen Hoeller
2022-06-14 14:00:28 +02:00
parent 933965b7b4
commit 4e1b9f1492
31 changed files with 78 additions and 245 deletions

View File

@@ -944,8 +944,8 @@ class XmlBeanFactoryTests {
xbf.getBean("rod2Accessor");
}
catch (BeanCreationException ex) {
assertThat(ex.toString().contains("touchy")).isTrue();
ex.printStackTrace();
assertThat(ex.toString().contains("touchy")).isTrue();
assertThat((Object) ex.getRelatedCauses()).isNull();
}
}
@@ -1370,7 +1370,7 @@ class XmlBeanFactoryTests {
reader.loadBeanDefinitions(INVALID_NO_SUCH_METHOD_CONTEXT);
assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() ->
xbf.getBean("constructorOverrides"))
.withMessageContaining("bogusMethod");
.satisfies(ex -> ex.getCause().getMessage().contains("bogusMethod"));
}
@Test

View File

@@ -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.
@@ -56,7 +56,7 @@ public class Spr12278Tests {
public void componentTwoSpecificConstructorsNoHint() {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new AnnotationConfigApplicationContext(BaseConfiguration.class, TwoSpecificConstructorsComponent.class))
.withMessageContaining(NoSuchMethodException.class.getName());
.withMessageContaining("No default constructor found");
}