Skip to content

Commit aa8cf19

Browse files
committed
Property actually throws exception for no write method found
Issue: SPR-15507 (cherry picked from commit 817e80c)
1 parent d643e57 commit aa8cf19

File tree

1 file changed

+5
-3
lines changed
  • spring-core/src/main/java/org/springframework/core/convert

1 file changed

+5
-3
lines changed

spring-core/src/main/java/org/springframework/core/convert/Property.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -144,10 +144,11 @@ private String resolveName() {
144144
return StringUtils.uncapitalize(this.readMethod.getName().substring(index));
145145
}
146146
else {
147-
int index = this.writeMethod.getName().indexOf("set") + 3;
147+
int index = this.writeMethod.getName().indexOf("set");
148148
if (index == -1) {
149149
throw new IllegalArgumentException("Not a setter method");
150150
}
151+
index += 3;
151152
return StringUtils.uncapitalize(this.writeMethod.getName().substring(index));
152153
}
153154
}
@@ -194,7 +195,8 @@ private MethodParameter resolveParameterType(MethodParameter parameter) {
194195
private Annotation[] resolveAnnotations() {
195196
Annotation[] annotations = annotationCache.get(this);
196197
if (annotations == null) {
197-
Map<Class<? extends Annotation>, Annotation> annotationMap = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
198+
Map<Class<? extends Annotation>, Annotation> annotationMap =
199+
new LinkedHashMap<Class<? extends Annotation>, Annotation>();
198200
addAnnotationsToMap(annotationMap, getReadMethod());
199201
addAnnotationsToMap(annotationMap, getWriteMethod());
200202
addAnnotationsToMap(annotationMap, getField());

0 commit comments

Comments
 (0)