[spring-extensions] 02/03: IDP-1047 Annotation ParameterName Discovery

Rod Widdowson rdw at steadingsoftware.com
Fri Sep 23 08:09:28 EDT 2016


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=e3bc1d2dc55da7a201f80525cc3a63cbea78c9f8

commit e3bc1d2dc55da7a201f80525cc3a63cbea78c9f8
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Sep 23 11:02:53 2016 +0100

    IDP-1047 Annotation ParameterName Discovery
    
    https://issues.shibboleth.net/jira/browse/IDP-1047
    
    Add better logging and fall into the default earlier if this class
    couldn't possibly be interesting to us.
---
 .../spring/util/AnnotationParameterNameDiscoverer.java  | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/util/AnnotationParameterNameDiscoverer.java b/src/main/java/net/shibboleth/ext/spring/util/AnnotationParameterNameDiscoverer.java
index 2bc2996..d552bc2 100644
--- a/src/main/java/net/shibboleth/ext/spring/util/AnnotationParameterNameDiscoverer.java
+++ b/src/main/java/net/shibboleth/ext/spring/util/AnnotationParameterNameDiscoverer.java
@@ -32,6 +32,8 @@ import org.springframework.core.ParameterNameDiscoverer;
 
 /**
  * An implementation of {@link ParameterNameDiscoverer} that is driven by the {@link ParameterName} Annotation.
+ *
+ * @since 5.3.0 (IdP 3.3.0)
  */
 public class AnnotationParameterNameDiscoverer extends DefaultParameterNameDiscoverer implements
         ParameterNameDiscoverer {
@@ -46,10 +48,10 @@ public class AnnotationParameterNameDiscoverer extends DefaultParameterNameDisco
     }
 
     /** Given the annotations for each parameter is it one of ours?
-     * @param annotations the annotations for the parametere
-     * @return the "name" if one of ours.
+     * @param annotations the annotations for the parameter
+     * @return the "name" if one of ours. null otherwise
      */
-    private String getMyAnnotation(final Annotation[] annotations) {
+    @Nullable private String getMyAnnotation(final Annotation[] annotations) {
         for (final Annotation a : annotations) {
             if (a instanceof ParameterName) {
                 final ParameterName param = (ParameterName) a;
@@ -66,16 +68,19 @@ public class AnnotationParameterNameDiscoverer extends DefaultParameterNameDisco
     @Override public String[] getParameterNames(final Constructor<?> ctor) {
 
         final Annotation[][] annotationsArray = ctor.getParameterAnnotations();
-
         if (annotationsArray.length == 0) {
+            // nothing to do
             return super.getParameterNames(ctor);
         }
 
         final String className = ctor.getDeclaringClass().getName();
-        boolean allPresent = true;
         final boolean isOurs = (className != null) && 
                 (className.startsWith("org.opensaml") || className.startsWith("net.shibboleth"));
+        if (!isOurs) {
+            return super.getParameterNames(ctor);
+        }
 
+        boolean allPresent = true;
         final String[] names = new String[annotationsArray.length];
 
         for (int index = 0; index < annotationsArray.length; index++) {
@@ -89,11 +94,11 @@ public class AnnotationParameterNameDiscoverer extends DefaultParameterNameDisco
             if (isOurs) {
                 log.warn("Constructor for class '{}' with {} parameters: "
                         + "Not all parameters are annotated with @ParameterName", className, annotationsArray.length);
+                log.debug("Types : {}", (Object)ctor.getParameterTypes());
             }
             return super.getParameterNames(ctor);
         }
         log.trace("Constructor for class '{}' with {} parameters called {}", className, names.length, names);
         return names;
     }
-
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list