[
https://issues.apache.org/jira/browse/OFBIZ-10638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754876#comment-16754876 ]
Mathieu Lirzin commented on OFBIZ-10638:
----------------------------------------
Hello Taher,
After studying “Java concurrency in practice” by Brian Goetz, I have updated [^OFBIZ-10638_Remove-StartupLoader-interface.patch] with the following change. The initial code for {{loadStartupLoaders}} with multiple loaders was the following:
{code:java}
synchronized (loaders) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
try {
Class<?> loaderClass = classloader.loadClass(startupLoaderName);
StartupLoader loader = (StartupLoader) loaderClass.newInstance();
loaders.add(loader); // add before loading, so unload can occur if error during loading
loader.load(config, ofbizCommands);
} catch (ReflectiveOperationException e) {
throw new StartupException(e);
}
}
{code}
my first patch was relaxing the invariants by removing the synchronization between the check of the server state and the loading of the component container:
{code:java}
if (serverState.get() == ServerState.STOPPING) {
return;
}
loader.load(config, ofbizCommands);
{code}
the updated patch reintroduce that invariant to preserve the initial concurrency semantics
{code:java}
synchronized (StartupControlPanel.class) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
loader.load(config, ofbizCommands);
}
{code}
To avoid delaying the close of that ticket, I have removed the extra refactoring patches which I keep for a later ticket.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)