From dcf5c41129df2c78c18f8f2de77fe833a8ca99fd Mon Sep 17 00:00:00 2001 From: David Gillingham Date: Wed, 13 Feb 2013 11:07:06 -0600 Subject: [PATCH] Issue #1515: Better handle notifications received after disposing VCParms. Change-Id: Ia73102329755303b504871ed55f2a294ef390126 Former-commit-id: 5b4de19ebdad89c95514ee4a3ae4ab7d0e645f7a [formerly 5b4de19ebdad89c95514ee4a3ae4ab7d0e645f7a [formerly ef9d97a4d0886df2072672b1cebc9b77e689308b]] Former-commit-id: ddcc84262a673f3f961cbc851928766edf4c8771 Former-commit-id: 874434cea9376e018164bf284e7b8e96738bac93 --- .../raytheon/viz/gfe/core/parm/VCParm.java | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java index eacbf16f61..eca517d0c3 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java @@ -26,6 +26,7 @@ import java.util.Date; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.RejectedExecutionException; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; @@ -76,6 +77,9 @@ import com.raytheon.viz.gfe.core.parm.vcparm.VCModule.VCInventory; * separate thread to prevent backup * in ParmListener's notification job * pool. + * Feb 13, 2013 #1515 dgilling Handle RejectedExecutionExceptions + * if notification is received after + * Parm disposal. * * * @@ -156,6 +160,12 @@ public class VCParm extends VParm implements IParmListChangedListener, */ @Override public void gridDataChanged(final ParmID parmId, final TimeRange validTime) { + synchronized (this) { + if (disposed) { + return; + } + } + Runnable onNotificationTask = new Runnable() { @Override @@ -200,7 +210,16 @@ public class VCParm extends VParm implements IParmListChangedListener, } }; - notificationWorkers.submit(onNotificationTask); + try { + notificationWorkers.submit(onNotificationTask); + } catch (RejectedExecutionException e) { + // received a notification after thread pool shutdown + // do nothing, but log + String message = "Parm " + + toString() + + " received GridDataChange notification after VCParm.dispose()."; + statusHandler.handle(Priority.EVENTB, message, e); + } } /* @@ -215,6 +234,12 @@ public class VCParm extends VParm implements IParmListChangedListener, @Override public void parmListChanged(final Parm[] parms, Parm[] deletions, Parm[] additions) { + synchronized (this) { + if (disposed) { + return; + } + } + Runnable onNotificationTask = new Runnable() { @Override @@ -239,7 +264,16 @@ public class VCParm extends VParm implements IParmListChangedListener, } }; - notificationWorkers.submit(onNotificationTask); + try { + notificationWorkers.submit(onNotificationTask); + } catch (RejectedExecutionException e) { + // received a notification after thread pool shutdown + // do nothing, but log + String message = "Parm " + + toString() + + " received ParmListChange notification after VCParm.dispose()."; + statusHandler.handle(Priority.EVENTB, message, e); + } } /* @@ -251,6 +285,12 @@ public class VCParm extends VParm implements IParmListChangedListener, */ @Override public void parmInventoryChanged(Parm parm, TimeRange timeRange) { + synchronized (this) { + if (disposed) { + return; + } + } + // It would be better to only update those griddata objects // that needed it. But... that is much more difficult // than this simple brute force method. This seems to be @@ -275,7 +315,16 @@ public class VCParm extends VParm implements IParmListChangedListener, } }; - notificationWorkers.submit(onNotificationTask); + try { + notificationWorkers.submit(onNotificationTask); + } catch (RejectedExecutionException e) { + // received a notification after thread pool shutdown + // do nothing, but log + String message = "Parm " + + toString() + + " received ParmInventoryChange notification after VCParm.dispose()."; + statusHandler.handle(Priority.EVENTB, message, e); + } } /*