OpenJPA
  1. OpenJPA
  2. OPENJPA-1755

MultiClassLoader relies on its underlying ClassLoaders for hashCode

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      The MultiClassLoader relies on its underlying ClassLoaders in its hashing algorithm. This is problematic if the underlying classloaders refuse to return a hash or if the classloader list changes over time.

      I ran into a problem that demanded a resolution to this issue when doing some work with OpenJPA in a Google AppEngine context. I don't have a stack trace handy.

      An effective-yet-ugly fix was to simply change the hashCode() implementation to return a constant value (I chose '1'). This clearly is a crappy hashing algorithm, but will always respect the hashing contract. And I don't think that we really put MultiClassLoaders into big maps or anything.

      1. OPENJPA-1755.txt
        0.5 kB
        Patrick Linskey

        Activity

        Hide
        Patrick Linskey added a comment -

        If this looks like a satisfactory hashCode impl to others, let me know and I'll commit the diff.

        Show
        Patrick Linskey added a comment - If this looks like a satisfactory hashCode impl to others, let me know and I'll commit the diff.
        Hide
        Rick Curtis added a comment -

        Any more context? I think anyone would be hard pressed to commit this change without more info.

        Show
        Rick Curtis added a comment - Any more context? I think anyone would be hard pressed to commit this change without more info.
        Hide
        Donald Woods added a comment -

        Patrick, was hashCode() throwing an Exception for you in your GAE scenario? If so, catching the exception, log a msg and then return 1 might be an acceptable compromise....

        Show
        Donald Woods added a comment - Patrick, was hashCode() throwing an Exception for you in your GAE scenario? If so, catching the exception, log a msg and then return 1 might be an acceptable compromise....

          People

          • Assignee:
            Unassigned
            Reporter:
            Patrick Linskey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development