ODE-1026: Acquire readLock while firing events to avoid deadlock
diff --git a/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java b/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
index fabd531..ba911a7 100644
--- a/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
+++ b/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
@@ -308,7 +308,9 @@
});
- // We want the events to be fired outside of the bounds of the writelock.
+
+ _rw.readLock().lock();
+ boolean readLockHeld = true;
try {
for (ProcessConfImpl process : processes) {
fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.DEPLOYED, process.getProcessId(), process.getDeploymentUnit()
@@ -316,11 +318,18 @@
fireStateChange(process.getProcessId(), process.getState(), process.getDeploymentUnit().getName());
}
} catch (Exception e) {
+ //need to unlock as undeploy operation will need a writeLock
+ _rw.readLock().unlock();
+ readLockHeld = false;
+
// A problem at that point means that engine deployment failed, we don't want the store to keep the du
__log.warn("Deployment failed within the engine, store undeploying process.", e);
undeploy(deploymentUnitDirectory);
if (e instanceof ContextException) throw (ContextException) e;
else throw new ContextException("Deployment failed within the engine. " + e.getMessage(), e);
+ } finally {
+ if(readLockHeld)
+ _rw.readLock().unlock();
}
return deployed;