Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2722

A key class for java.util.Map that implements hashCode cause StackOverflowError during get()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.5.4
    • 1.5.5
    • None
    • None

    Description

      The following script causes StackOverflowError:

      Map map = new HashMap();
      map.put(new MyKey("1"), "1");
      map.get(new MyKey("1"));
      
      public class MyKey
      {
          private String m_key;
      
          public MyKey (String key)
          {
              m_key = key;
          }
      
          public String getKey ()
          {
             return m_key;
          }
      
          public int hashCode ()
          {
              return m_key.hashCode();
          }
      
          public boolean equals (Object o)
          {
              if (this == o) return true;
              if (!(o instanceof MyKey)) return false;
              MyKey key = (MyKey) o;
              return key.getKey().equals(m_key);
          }
      }
      

      Attachments

        1. stackTrace.txt
          77 kB
          Alexander K.

        Activity

          People

            paulk Paul King
            alexkra Alexander K.
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: