You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2011/02/24 01:05:02 UTC

svn commit: r1073995 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java

Author: mbenson
Date: Thu Feb 24 00:05:02 2011
New Revision: 1073995

URL: http://svn.apache.org/viewvc?rev=1073995&view=rev
Log:
address the invalidity of null annotation members

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java?rev=1073995&r1=1073994&r2=1073995&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java Thu Feb 24 00:05:02 2011
@@ -148,7 +148,12 @@ public class AnnotationUtils {
         int result = 0;
         Class<? extends Annotation> type = a.annotationType();
         for (Method m : type.getDeclaredMethods()) {
-            result += hashMember(m.getName(), m.invoke(a));
+            Object value = m.invoke(a);
+            if (value == null) {
+                throw new IllegalStateException(String.format("Annotation method %s returned null",
+                        m));
+            }
+            result += hashMember(m.getName(), value);
         }
         return result;
     }
@@ -198,9 +203,6 @@ public class AnnotationUtils {
     private static int hashMember(String name, Object value) throws IllegalArgumentException,
             IllegalAccessException, InvocationTargetException {
         int part1 = name.hashCode() * 127;
-        if (value == null) {
-            return part1;
-        }
         if (value.getClass().isArray()) {
             return part1 ^ arrayMemberHash(value.getClass().getComponentType(), value);
         }