Browse Source

Catch Error for SourceHttpMessageConverter in WebMvcConfigurationSupport

Prior to this commit, the addDefaultHttpMessageConverters() method in
WebMvcConfigurationSupport caught Throwable for SourceHttpMessageConverter
instantiation; whereas, the rest of the code base correctly catches Error
for SourceHttpMessageConverter instantiation (to handle errors such as
NoClassDefFoundError).

Throwable should not be caught since it can mask other categories of
failures (such as configuration errors).

This commit therefore switches to catching Error for SourceHttpMessageConverter
instantiation in WebMvcConfigurationSupport.

Closes gh-29537
pull/29589/head
Sam Brannen 3 years ago
parent
commit
72b44cebea
  1. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java

6
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java

@ -1,5 +1,5 @@ @@ -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.
@ -907,8 +907,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv @@ -907,8 +907,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
try {
messageConverters.add(new SourceHttpMessageConverter<>());
}
catch (Throwable ex) {
// Ignore when no TransformerFactory implementation is available...
catch (Error err) {
// Ignore when no TransformerFactory implementation is available
}
}
messageConverters.add(new AllEncompassingFormHttpMessageConverter());

Loading…
Cancel
Save