@@ -725,6 +725,8 @@ public void setRegistration(final ServiceRegistration<ServiceComponentRuntime> r
725725 }
726726
727727 class UpdateChangeCountProperty implements Runnable {
728+ // TODO Is 100 ms an appropriate minimum?
729+ private static final long MIN_ALLOWED_DELAY = 100 ;
728730 private volatile ServiceRegistration <ServiceComponentRuntime > registration ;
729731 private final long maxNumberOfNoChanges ;
730732 private final long delay ;
@@ -736,8 +738,15 @@ class UpdateChangeCountProperty implements Runnable {
736738
737739 public UpdateChangeCountProperty (long delay )
738740 {
741+ if (delay < MIN_ALLOWED_DELAY ) {
742+ m_logger .log (Level .INFO ,
743+ "The service change count timeout {0} is less than the allowable minimum {1}. Using the allowable minimum instead." , null ,
744+ delay , MIN_ALLOWED_DELAY );
745+ delay = MIN_ALLOWED_DELAY ;
746+ }
739747 this .delay = delay ;
740- // calculate the max number of no changes; must be at least 1 to avoid missing events
748+ // Calculate the max number of no changes; must be at least 1 to avoid missing events
749+ // The calculation is intended to let at least 10 seconds pass before canceling the scheduledFuture
741750 maxNumberOfNoChanges = Long .max (10000 / delay , 1 );
742751 }
743752
@@ -764,7 +773,12 @@ public void run()
764773 return ;
765774 }
766775 try {
767- Long registeredChangeCount = (Long ) currentReg .getReference ().getProperty (PROP_CHANGECOUNT );
776+ Long registeredChangeCount = null ;
777+ try {
778+ registeredChangeCount = (Long ) currentReg .getReference ().getProperty (PROP_CHANGECOUNT );
779+ } catch ( final IllegalStateException ise ) {
780+ // we ignore this as this might happen on shutdown
781+ }
768782 if (registeredChangeCount == null || registeredChangeCount .longValue () != changeCount .get ()) {
769783 try
770784 {
0 commit comments