Uhmm I try to explain better, basically is a strange behavior I fighting
with.

I've got a singleton.
Every core have an handler that try to obtain the object by going to
that singleton getInstance() method, which look like this:

public synchronized static SingletonObjectDemo getInstance(){
    if (singletonObject == null){
        singletonObject = new SingletonObjectDemo ();
    }  
    return singletonObject;
}

However every one obtain a different object.

It is not related to the singleton, AFAIK, as I tested it with a simple
multhread app, and I always got the object created one time
(singletonObject = new getInstance()), while other calls just receive
the already created object.

While if the handler try to call getInstance(), the first time (the
first time /for each core/, and here is the point), init a brand new
object (other call to getInstance() inside the same core works fine)

Ryan McKinley wrote:
>
>>
>> Is there a way to bypass that, and to use singletons in a "singleton"
>> fashion between cores?
>> Btw: Cores do see MultiCore as a singleton, i.e. all handler see the
>> same object, so I could get around this problem using MultiCore to get
>> cores..., but I would like to understand why cores doesn't seems to
>> share singletons. I may be wrong, but this used to work with (old)
>> Henri's solr215 patch.
>>
>
> I don't totally understand what issue you are having.  What is the
> specific function call that is not behaving how you would hope?
>
> Is it that: private static SolrCore instance; is not really a
> singleton?  and that SolrCore.getSolrCore() returns the last SolrCore
> initalized rather then the first one?
>
> My thinking with this is that the 'instance' variable is @Deprecated
> and should go away (along with getSolrCore).  Any requests to get a
> SolrCore should be made with the real singleton class MultiCore --
> that seems cleaner then adding a static registry to SolrCore.
>
> Is that what you are refering to?
>
> ryan
>
>

Reply via email to