From 085449cf1ed604bf405a7d1b0bb5bd75771df44e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 26 Jul 2010 20:14:57 +0000 Subject: [PATCH] fixed @PathVariable regression in combination with ConversionService usage on DataBinder git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3504 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../springframework/beans/SimpleTypeConverter.java | 12 ++++++++++-- .../validation/AbstractPropertyBindingResult.java | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/SimpleTypeConverter.java b/org.springframework.beans/src/main/java/org/springframework/beans/SimpleTypeConverter.java index a24d119a453..a75e5fd3625 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/SimpleTypeConverter.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/SimpleTypeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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. @@ -17,6 +17,8 @@ package org.springframework.beans; import org.springframework.core.MethodParameter; +import org.springframework.core.convert.ConversionException; +import org.springframework.core.convert.ConverterNotFoundException; /** * Simple implementation of the TypeConverter interface that does not operate @@ -46,12 +48,18 @@ public class SimpleTypeConverter extends PropertyEditorRegistrySupport implement try { return this.typeConverterDelegate.convertIfNecessary(value, requiredType, methodParam); } - catch (IllegalArgumentException ex) { + catch (ConverterNotFoundException ex) { + throw new ConversionNotSupportedException(value, requiredType, ex); + } + catch (ConversionException ex) { throw new TypeMismatchException(value, requiredType, ex); } catch (IllegalStateException ex) { throw new ConversionNotSupportedException(value, requiredType, ex); } + catch (IllegalArgumentException ex) { + throw new TypeMismatchException(value, requiredType, ex); + } } } diff --git a/org.springframework.context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java b/org.springframework.context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java index 9478fa8626f..b75e9bb9898 100644 --- a/org.springframework.context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java +++ b/org.springframework.context/src/main/java/org/springframework/validation/AbstractPropertyBindingResult.java @@ -57,7 +57,9 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul public void initConversion(ConversionService conversionService) { Assert.notNull(conversionService, "ConversionService must not be null"); this.conversionService = conversionService; - getPropertyAccessor().setConversionService(conversionService); + if (getTarget() != null) { + getPropertyAccessor().setConversionService(conversionService); + } } /**