ICEfaces
  1. ICEfaces
  2. ICE-9671

WindowScopeManager doesn't find PreDestroy annotations on ancestor classes

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      all

      Description

      Code snippet from WindowScopeManager:

          private static void callAnnotatedMethod(Object object, Class annotation) {
              Class theClass = object.getClass();
              try {
                  while (null != theClass) {
                      Method[] methods = object.getClass().getDeclaredMethods();
                      for (Method method : methods) {
                          if (method.isAnnotationPresent(annotation)) {
                              method.setAccessible(true);
                              method.invoke(object);
                              return;
                          }
                      }
                      theClass = theClass.getSuperclass();
                  }
              } catch (Exception e) {
                  log.log(Level.WARNING, "Failed to invoke" + annotation + " on " + theClass, e);
              }
          }

      This code finds annotations on a class but not on any ancestor classes.

      The line:

          Method[] methods = object.getClass().getDeclaredMethods();

      should be replaced with:

          Method[] methods = theClass.getDeclaredMethods();

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Damon Horrell
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: