4 Replies Latest reply on Aug 9, 2013 3:02 AM by Oliver Pfau

    Deadlock in unit test initializing static member

    Oliver Pfau Newbie

      Hi,

       

      I am quite new with CDI. In my junit test with CDI-unit I added a cache as static member in a dao like this:

       

      private static Map<CacheKey, Map<String, String>> CACHE = new HashMap<>();

       

      This leads to a deadlock when I execute the test.

       

      If I init the cache like this:

       

      @PostConstruct

                public void afterInjection()

                {

                               CACHE = new HashMap<>();

        }

       

      There is no deadlock. I am using weld 2.0.2.Final in the test.

      Does anyone know the reason?

       

      Cheers

      Oliver