Skip to content

Commit

Permalink
Property actually throws exception for no write method found
Browse files Browse the repository at this point in the history
Issue: SPR-15507
(cherry picked from commit 817e80c)
  • Loading branch information
jhoeller committed May 4, 2017
1 parent d643e57 commit aa8cf19
Showing 1 changed file with 5 additions and 3 deletions.
@@ -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.
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -194,7 +195,8 @@ private MethodParameter resolveParameterType(MethodParameter parameter) {
private Annotation[] resolveAnnotations() {
Annotation[] annotations = annotationCache.get(this);
if (annotations == null) {
Map<Class<? extends Annotation>, Annotation> annotationMap = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
Map<Class<? extends Annotation>, Annotation> annotationMap =
new LinkedHashMap<Class<? extends Annotation>, Annotation>();
addAnnotationsToMap(annotationMap, getReadMethod());
addAnnotationsToMap(annotationMap, getWriteMethod());
addAnnotationsToMap(annotationMap, getField());
Expand Down

0 comments on commit aa8cf19

Please sign in to comment.