Menu

Concurrency problem in SerializableMethod

2015-05-01
2015-05-11
  • Andrew Malota

    Andrew Malota - 2015-05-01

    We've run into a problem using OVal as a part of the Play framework.

    There appears to be a concurrency problem in SerializableMethod.java:
    https://sourceforge.net/p/oval/code/HEAD/tree/trunk/src/main/java/net/sf/oval/internal/util/SerializableMethod.java#l31
    specifically:
    private static final WeakHashMap<Method, SerializableMethod=""> CACHE = new WeakHashMap();
    is static, but WeakHashMap isn't thread safe. On at least Java(TM) SE Runtime Environment (build 1.7.0_67-b01), if two threads hit that cache at "just the right time," one of them will spinlock forever.

    I believe the fix is simply to wrap in some Concurrent variant.

     

    Last edit: Andrew Malota 2015-05-01
  • Seb

    Seb - 2015-05-11

    Hi Andrew, thanks for reporting the issue. I committed a fix and built a snapshot version.

    http://oval.sourceforge.net/mvn-repo/snapshot/net/sf/oval/oval/1.85-SNAPSHOT/

    Regards,
    Seb

     

Log in to post a comment.