Results 1 to 2 of 2

Thread: GetObject of a singleton crash in multi-threading

  1. #1
    Join Date
    Dec 2007
    Posts
    4

    Default GetObject of a singleton crash in multi-threading

    In case of use GetObject for a singleton by a multi-threading access, sometime there is an exception while execute the instruction
    "singletonsInCreation.Remove(name);" in Spring.Objects.Factory.Support.AbstractObjectFacto ry.AfterSingletonCreation because the Remove(string key) of the OrderedDictionary class call the RemoveAt(int index) with the index of the key, but two concurrent Remove could change the index generating an Index out of range inside the RemoveAt.

    For now, I have resolved with a lock on singletonsInCreation inside the BeforeSingletonCreation and AfterSingletonCreation.

    Bye, bye.
    Cristiano.

  2. #2
    Join Date
    Nov 2006
    Posts
    54

    Default

    I also get this (well actually I believe that I see evidence of this occurring) in that I (intermittently) end up with errors from spring telling me that Objects are in creation, possibly caused by a cyclic reference.. however the beans involved don't seem to have any cyclic references, and the problem appears to be that they weren't correctly removed from the singletonsInCreation internal variable.

    Since I am already extendind the WebApplicationContext, I am looking at overriding the method that returns the internal ObjectFactory and replacing the implementation with one that has a course-grain lock

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •