Uploaded image for project: 'Commons OGNL'
  1. Commons OGNL
  2. OGNL-233

ClassCacheHandler should return a handler with a key that is the nearest class (interface) to the forClass in the hierarchy tree

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Core Runtime
    • Labels:
      None
    • Flags:
      Patch

      Description

      ClassCacheHandler enumerates over the forClass's interfaces and superclasses to find a match key class. But consider the following senario:

      interface A implements java.util.Collection
      class B extends java.util.AbstractList implements A

      Now if ClassCacheHandler.getHandler(B, handlers) is invoked, and assuming handlers is an empty ClassCache, according to the current enumeration logic used by ClassCacheHandler, classes (interfaces) will be enumerated in the following order:

      class B
      interface A
      interface java.util.Collection
      interface java.lang.Iterable
      interface java.io.Serializable
      class java.util.AbstractList
      interface java.util.List
      interface java.util.Collection
      interface java.lang.Iterable
      class java.util.AbstractCollection
      interface java.util.Collection
      interface java.lang.Iterable

      if both java.util.Collection and java.util.List are present as keys in the handlers, since java.util.Collection is enumerated first, then it will be matched, instead of java.util.List.

      The expected behaviour should be java.util.List is matched, because it is nearer to class B in the hierarchy tree.

        Attachments

        1. ClassCacheHandlerTest.java
          1 kB
          Maurizio Cucchiara
        2. ClassHierachy.png
          21 kB
          Maurizio Cucchiara

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              azuo_lee Azuo Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: