Repository: commons-lang
Updated Branches:
  refs/heads/master 1e9e36640 -> c56b87d6e


LANG-1354: FieldUtils should ignore any synthetic fields


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/c56b87d6
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/c56b87d6
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/c56b87d6

Branch: refs/heads/master
Commit: c56b87d6efe530590b6d9a07e41ca00af208ce37
Parents: 1e9e366
Author: Chas Honton <c...@apache.org>
Authored: Tue Oct 10 20:52:50 2017 -0700
Committer: Chas Honton <c...@apache.org>
Committed: Tue Oct 10 20:52:50 2017 -0700

----------------------------------------------------------------------
 pom.xml                                                  | 11 +++++++++++
 src/changes/changes.xml                                  |  1 +
 .../org/apache/commons/lang3/reflect/FieldUtils.java     | 11 +++++++++--
 src/site/resources/profile.cobertura                     |  0
 src/site/resources/profile.jacoco                        |  0
 5 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c56b87d6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 81f2d30..74d51a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -704,6 +704,17 @@
   <reporting>
     <plugins>
       <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>report</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+      <plugin>
         <artifactId>maven-checkstyle-plugin</artifactId>
         <version>${checkstyle.plugin.version}</version>
         <configuration>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c56b87d6/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c4491ee..5239f9c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.7" date="2017-MM-DD" description="New features and bug 
fixes. Requires Java 7.">
+    <action issue="LANG-1354" type="fix" dev="chas" due-to="Yegor 
Koldov">FieldUtils should ignore any synthetic fields</action>
     <action issue="LANG-1355" type="add" dev="ggregory" due-to="Chas 
Honton">TimeZone.getTimeZone() in FastDateParser causes resource contention (PR 
#296.)</action>
     <action issue="LANG-1348" type="fix" dev="pschumacher" 
due-to="mbusso">StackOverflowError on TypeUtils.toString(...) for a generic 
return type of Enum.valueOf</action>
     <action issue="LANG-1346" type="update" dev="pschumacher">Remove 
deprecation from RandomStringUtils</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c56b87d6/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java 
b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
index c4cccca..c45a73a 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
@@ -187,6 +187,7 @@ public class FieldUtils {
 
     /**
      * Gets all fields of the given class and its parents (if any).
+     * Does not return any synthetic fields.
      *
      * @param cls
      *            the {@link Class} to query
@@ -202,6 +203,7 @@ public class FieldUtils {
 
     /**
      * Gets all fields of the given class and its parents (if any).
+     * Does not return any synthetic fields.
      *
      * @param cls
      *            the {@link Class} to query
@@ -215,8 +217,11 @@ public class FieldUtils {
         final List<Field> allFields = new ArrayList<>();
         Class<?> currentClass = cls;
         while (currentClass != null) {
-            final Field[] declaredFields = currentClass.getDeclaredFields();
-            Collections.addAll(allFields, declaredFields);
+            for(final Field declaredField : currentClass.getDeclaredFields()) {
+                if(!declaredField.isSynthetic()) {
+                    allFields.add(declaredField);
+                }
+            }
             currentClass = currentClass.getSuperclass();
         }
         return allFields;
@@ -224,6 +229,8 @@ public class FieldUtils {
 
     /**
      * Gets all fields of the given class and its parents (if any) that are 
annotated with the given annotation.
+     * Does not return any synthetic fields.
+     *
      * @param cls
      *            the {@link Class} to query
      * @param annotationCls

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c56b87d6/src/site/resources/profile.cobertura
----------------------------------------------------------------------
diff --git a/src/site/resources/profile.cobertura 
b/src/site/resources/profile.cobertura
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/c56b87d6/src/site/resources/profile.jacoco
----------------------------------------------------------------------
diff --git a/src/site/resources/profile.jacoco 
b/src/site/resources/profile.jacoco
new file mode 100644
index 0000000..e69de29

Reply via email to