diff --git a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/MessageProducer.java b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/MessageProducer.java index 352e92970c..5f19ae9099 100644 --- a/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/MessageProducer.java +++ b/edexOsgi/com.raytheon.uf.edex.esb.camel/src/com/raytheon/uf/edex/esb/camel/MessageProducer.java @@ -375,8 +375,14 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy { * track the thread this context is using for proper dependency * management. */ + CamelContext prev = MessageProducer.this.currentThreadContext + .get(); MessageProducer.this.currentThreadContext.set(context); - target.process(exchange); + try { + target.process(exchange); + } finally { + MessageProducer.this.currentThreadContext.set(prev); + } } @Override @@ -385,12 +391,16 @@ public class MessageProducer implements IMessageProducer, InterceptStrategy { * track the thread this context is using for proper dependency * management. */ + CamelContext prev = MessageProducer.this.currentThreadContext + .get(); MessageProducer.this.currentThreadContext.set(context); try { target.process(exchange); } catch (Throwable e) { exchange.setException(e); + } finally { + MessageProducer.this.currentThreadContext.set(prev); } callback.done(true); return true; diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.modelsounding/src/com/raytheon/uf/edex/plugin/modelsounding/ModelSoundingPersistenceManager.java b/edexOsgi/com.raytheon.uf.edex.plugin.modelsounding/src/com/raytheon/uf/edex/plugin/modelsounding/ModelSoundingPersistenceManager.java index 0528cd33c4..d9a3fb6e27 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.modelsounding/src/com/raytheon/uf/edex/plugin/modelsounding/ModelSoundingPersistenceManager.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.modelsounding/src/com/raytheon/uf/edex/plugin/modelsounding/ModelSoundingPersistenceManager.java @@ -43,7 +43,7 @@ import com.raytheon.uf.edex.core.IContextStateProcessor; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jul 17, 2013 2161 bkowal Initial creation. - * Mar 11, 2014 2726 rjpeter Graceful shutdown. + * Mar 11, 2014 2726 rjpeter Graceful shutdown, don't forward empty pdo lists. * * * @author bkowal @@ -99,14 +99,16 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor { if (container != null) { List pdoList = container.getPdos(); - PluginDataObject[] pdos = pdoList - .toArray(new PluginDataObject[pdoList.size()]); - try { - EDEXUtil.getMessageProducer().sendSync( - "modelSoundingPersistIndexAlert", pdos); - } catch (EdexException e) { - logger.error("Failed to persist " + pdos.length - + " PluginDataObject(s)!", e); + if ((pdoList != null) && !pdoList.isEmpty()) { + PluginDataObject[] pdos = pdoList + .toArray(new PluginDataObject[pdoList.size()]); + try { + EDEXUtil.getMessageProducer().sendSync( + "modelSoundingPersistIndexAlert", pdos); + } catch (EdexException e) { + logger.error("Failed to persist " + pdos.length + + " PluginDataObject(s)!", e); + } } } } catch (Throwable e) { @@ -125,14 +127,16 @@ public class ModelSoundingPersistenceManager implements IContextStateProcessor { protected void storeContainer(ModelSoundingStorageContainer container) { List pdoList = container.getPdos(); - PluginDataObject[] pdos = pdoList.toArray(new PluginDataObject[pdoList - .size()]); - try { - EDEXUtil.getMessageProducer().sendSync( - "modelSoundingPersistIndexAlert", pdos); - } catch (EdexException e) { - logger.error("Failed to persist " + pdos.length - + " PluginDataObject(s)!", e); + if ((pdoList != null) && !pdoList.isEmpty()) { + PluginDataObject[] pdos = pdoList + .toArray(new PluginDataObject[pdoList.size()]); + try { + EDEXUtil.getMessageProducer().sendSync( + "modelSoundingPersistIndexAlert", pdos); + } catch (EdexException e) { + logger.error("Failed to persist " + pdos.length + + " PluginDataObject(s)!", e); + } } }