Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] PersistenceProvider.createEntityManagerFactory() not work correctly when emSetupImpl.isUndeployed() returns true

Hello all,

I am using EclipseLink 2.3.2.
When I call PersistenceProvider.createEntityManagerFactory(), A
PersistenceException occurs rarely.

I think that there is a problem in the following parts.
in PersistenceProvider.createEntityManagerFactory():
[Line.123 of eclipselink-src-2.3.2.v20111125-r10461]
[Line.123 of eclipselink-src-2.3.3.v20120629-r11760]
[Line.123 of eclipselink-src-2.4.0.v20120608-r11652]

// synchronized to prevent undeploying by other threads.
boolean undeployed = false;
synchronized(emSetupImpl) {
    if(emSetupImpl.isUndeployed()) {
        undeployed = true;
    }
    // emSetupImpl has been already predeployed, predeploy will just
increment factoryCount.
    emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(),
nonNullProperties);
}
if(undeployed) {
    // after the emSetupImpl has been obtained from emSetupImpls
    // it has been undeployed by factory.close() in another thread - start
all over again.
    return createEntityManagerFactory(emName, properties);
}


I think if emSetupImpl.isUndeployed() is true, do not call
emSetupImpl.predeploy().
Considering processing UNDEPLOYED in the part under it,
I think that it should become the following code:

synchronized(emSetupImpl) {
    if(emSetupImpl.isUndeployed()) {
        undeployed = true;
    } else {
        // emSetupImpl has been already predeployed, predeploy will just
increment factoryCount.
        emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(),
nonNullProperties);
    }
}


What do you think?
Thanks.

P.S: Sorry for my bad English.

-- 
TH
tech-ml@xxxxxxxxxx 



--
View this message in context: http://eclipse.1072660.n5.nabble.com/PersistenceProvider-createEntityManagerFactory-not-work-correctly-when-emSetupImpl-isUndeployed-retue-tp156467.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.


Back to the top