DATACMNS-616 - Fixed field value lookup for private fields in AnnotationDetectionFieldCallback.

We now make the field detected by the callback accessible so that the value lookup doesn't fail for private fields. Added a few more unit tests to verify behavior.
This commit is contained in:
Oliver Gierke
2014-12-17 16:15:07 +01:00
parent 55d988e7b7
commit 013f97899e
2 changed files with 82 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012 the original author or authors.
* Copyright 2012-2014 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.
@@ -23,7 +23,7 @@ import org.springframework.util.ReflectionUtils;
import org.springframework.util.ReflectionUtils.FieldCallback;
/**
* A {@link FieldCallback} that will inspect each field for a given annotation. Thie fields type can then be accessed
* A {@link FieldCallback} that will inspect each field for a given annotation. This field's type can then be accessed
* afterwards.
*
* @author Oliver Gierke
@@ -55,8 +55,11 @@ public class AnnotationDetectionFieldCallback implements FieldCallback {
}
Annotation annotation = field.getAnnotation(annotationType);
if (annotation != null) {
this.field = field;
ReflectionUtils.makeAccessible(this.field);
}
}