From db2a10a1eb0d4bb61e33d287dfd8c38a968de56e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 26 Jul 2010 20:33:34 +0000 Subject: [PATCH] avoid double ConversionFailedException nesting git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3505 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../core/convert/support/ConversionUtils.java | 3 +++ .../web/servlet/config/MvcNamespaceTests.java | 14 ++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java b/org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java index 4bdcabf9007..88731032e4e 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java @@ -35,6 +35,9 @@ abstract class ConversionUtils { try { return converter.convert(source, sourceType, targetType); } + catch (ConversionFailedException ex) { + throw ex; + } catch (Exception ex) { throw new ConversionFailedException(sourceType, targetType, source, ex); } diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 6fea3e01a26..281bbb8fbbc 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -16,24 +16,18 @@ package org.springframework.web.servlet.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - import java.util.Date; import java.util.Locale; - import javax.validation.Valid; import javax.validation.constraints.NotNull; +import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; + +import org.springframework.beans.TypeMismatchException; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.ConversionService; import org.springframework.core.io.ClassPathResource; import org.springframework.format.annotation.DateTimeFormat; @@ -120,7 +114,7 @@ public class MvcNamespaceTests { assertTrue(handler.recordedValidationError); } - @Test(expected=ConversionFailedException.class) + @Test(expected=TypeMismatchException.class) public void testCustomConversionService() throws Exception { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext); reader.loadBeanDefinitions(new ClassPathResource("mvc-config-custom-conversion-service.xml", getClass()));