Skip to content

Commit 72b44ce

Browse files
committed
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
1 parent 1ee3777 commit 72b44ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 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.
@@ -907,8 +907,8 @@ protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?
907907
try {
908908
messageConverters.add(new SourceHttpMessageConverter<>());
909909
}
910-
catch (Throwable ex) {
911-
// Ignore when no TransformerFactory implementation is available...
910+
catch (Error err) {
911+
// Ignore when no TransformerFactory implementation is available
912912
}
913913
}
914914
messageConverters.add(new AllEncompassingFormHttpMessageConverter());

0 commit comments

Comments
 (0)