Browse Source

avoid double ConversionFailedException nesting

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3505 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 16 years ago
parent
commit
db2a10a1eb
  1. 3
      org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
  2. 14
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java

3
org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java

@ -35,6 +35,9 @@ abstract class ConversionUtils { @@ -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);
}

14
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java

@ -16,24 +16,18 @@ @@ -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 { @@ -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()));

Loading…
Cancel
Save