Menu

#228 New Detector: Static HashMaps and HashSets

3.x
closed-rejected
detectors (11)
5
2017-10-22
2010-04-28
Anonymous
No

Analogous to the Static Calendar Detector I created a static HashMap and HashSet Detector. Just today we (again) were hit by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6423457 (causing 100% CPU in HashMap.get()). We needed to restart the whole app-server to get it working again.

I did not know how to detect assignments of HashMap to Map references, maybe someone could either add that or tell me how to do it.

Discussion

  • Anonymous

    Anonymous - 2010-04-28

    New Detector class, patches for messages.xml, findbugs.xml and a test case file

     

    Last edit: Anonymous 2017-09-04
  • Keith Lea

    Keith Lea - 2010-06-04

    Could you give us more context? There are definitely situations where you might want to have a static map/set. Was your code in a servlet?

     
  • Keith Lea

    Keith Lea - 2010-06-04
    • assigned_to: nobody --> kano
    • status: open --> closed-out-of-date
     
  • Keith Lea

    Keith Lea - 2010-06-04

    oops! accidentally marked "out of date."

     
  • Keith Lea

    Keith Lea - 2010-06-04
    • status: closed-out-of-date --> open
     
  • David Harkness

    David Harkness - 2014-02-07

    Given that the original problem has been declared "pilot error," we should probably close this. From the end of the linked bug report:

    EVALUATION

    Doug Lea writes:

    "This is a classic symptom of an incorrectly synchronized use of HashMap. Clearly, the submitters need to use a thread-safe HashMap. If they upgraded to Java 5, they could just use ConcurrentHashMap. If they can't do this yet, they can use either the pre-JSR166 version, or better, the unofficial backport as mentioned by Martin. If they can't do any of these, they can use Hashtable or synchhronizedMap wrappers, and live with poorer performance. In any case, it's not a JDK or JVM bug."

    I agree that the presence of a corrupted data structure alone does not indicate a bug in the JDK.

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19

    Please rebase the patch on latest git state.

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19
    • status: open --> pending
    • assigned_to: Keith Lea --> Andrey Loskutov
    • Group: 3.0.0 --> 3.0.1
     
  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Status: pending --> closed-rejected
     

Log in to post a comment.