From aa8cf190d3d893f3fb34e8f0492114988b7c3b26 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 2 May 2017 21:16:31 +0200 Subject: [PATCH] Property actually throws exception for no write method found Issue: SPR-15507 (cherry picked from commit 817e80c) --- .../java/org/springframework/core/convert/Property.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/convert/Property.java b/spring-core/src/main/java/org/springframework/core/convert/Property.java index 0da18ee69d5a..081bb0ee309b 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/Property.java +++ b/spring-core/src/main/java/org/springframework/core/convert/Property.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -144,10 +144,11 @@ private String resolveName() { return StringUtils.uncapitalize(this.readMethod.getName().substring(index)); } else { - int index = this.writeMethod.getName().indexOf("set") + 3; + int index = this.writeMethod.getName().indexOf("set"); if (index == -1) { throw new IllegalArgumentException("Not a setter method"); } + index += 3; return StringUtils.uncapitalize(this.writeMethod.getName().substring(index)); } } @@ -194,7 +195,8 @@ private MethodParameter resolveParameterType(MethodParameter parameter) { private Annotation[] resolveAnnotations() { Annotation[] annotations = annotationCache.get(this); if (annotations == null) { - Map, Annotation> annotationMap = new LinkedHashMap, Annotation>(); + Map, Annotation> annotationMap = + new LinkedHashMap, Annotation>(); addAnnotationsToMap(annotationMap, getReadMethod()); addAnnotationsToMap(annotationMap, getWriteMethod()); addAnnotationsToMap(annotationMap, getField());