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

@@ -598,8 +598,7 @@ class RestTemplateTests {
assertThatExceptionOfType(ResourceAccessException.class).isThrownBy(() ->
template.getForObject(url, String.class))
.withMessage("I/O error on GET request for \"https://example.com/resource\": " +
"Socket failure; nested exception is java.io.IOException: Socket failure");
.withMessage("I/O error on GET request for \"https://example.com/resource\": Socket failure");
}
@Test // SPR-15900
@@ -615,8 +614,7 @@ class RestTemplateTests {
assertThatExceptionOfType(ResourceAccessException.class).isThrownBy(() ->
template.getForObject(uri, String.class))
.withMessage("I/O error on GET request for \"https://example.com/resource\": " +
"Socket failure; nested exception is java.io.IOException: Socket failure");
.withMessage("I/O error on GET request for \"https://example.com/resource\": Socket failure");
}
@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.
@@ -47,7 +47,7 @@ public class Spr8510Tests {
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
cll.contextInitialized(new ServletContextEvent(sc)))
.withMessageEndingWith("Could not open ServletContext resource [/programmatic.xml]");
.withMessageEndingWith("ServletContext resource [/programmatic.xml]");
}
/**
@@ -68,7 +68,7 @@ public class Spr8510Tests {
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
cll.contextInitialized(new ServletContextEvent(sc)))
.withMessageEndingWith("Could not open ServletContext resource [/from-init-param.xml]");
.withMessageEndingWith("ServletContext resource [/from-init-param.xml]");
}
/**
@@ -86,7 +86,7 @@ public class Spr8510Tests {
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
cll.contextInitialized(new ServletContextEvent(sc)))
.withMessageEndingWith("Could not open ServletContext resource [/from-init-param.xml]");
.withMessageEndingWith("ServletContext resource [/from-init-param.xml]");
}
/**
@@ -108,7 +108,7 @@ public class Spr8510Tests {
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
cll.contextInitialized(new ServletContextEvent(sc)))
.withMessageEndingWith("Could not open ServletContext resource [/from-init-param.xml]");
.withMessageEndingWith("ServletContext resource [/from-init-param.xml]");
}
/**
@@ -127,7 +127,7 @@ public class Spr8510Tests {
assertThatExceptionOfType(Throwable.class).isThrownBy(() ->
cll.contextInitialized(new ServletContextEvent(sc)))
.withMessageEndingWith("Could not open ServletContext resource [/WEB-INF/applicationContext.xml]");
.withMessageEndingWith("ServletContext resource [/WEB-INF/applicationContext.xml]");
}
/**