1717import io .deephaven .engine .table .impl .perf .UpdatePerformanceTracker ;
1818import io .deephaven .engine .table .impl .sources .LongSingleValueSource ;
1919import io .deephaven .engine .testutil .TstUtils ;
20+ import io .deephaven .engine .updategraph .TerminalNotification ;
2021import io .deephaven .engine .updategraph .UpdateGraph ;
2122import io .deephaven .engine .util .TableTools ;
2223import io .deephaven .util .SafeCloseable ;
2627import org .junit .*;
2728
2829import java .nio .file .Path ;
30+ import java .util .ArrayList ;
2931import java .util .Collections ;
32+ import java .util .List ;
3033import java .util .concurrent .*;
3134
3235import static io .deephaven .engine .context .TestExecutionContext .OPERATION_INITIALIZATION ;
@@ -170,6 +173,7 @@ public void testSimpleModify() {
170173 @ Test
171174 public void testRefreshRace () throws ExecutionException , InterruptedException , TimeoutException {
172175 final EventDrivenUpdateGraph eventDrivenUpdateGraph = EventDrivenUpdateGraph .newBuilder ("TestEDUG" ).build ();
176+ final List <Runnable > retainedReferences = new ArrayList <>();
173177
174178 final MutableInt sourceRefreshCount = new MutableInt (0 );
175179 final Runnable sleepingSource = () -> {
@@ -180,6 +184,7 @@ public void testRefreshRace() throws ExecutionException, InterruptedException, T
180184 Assert .fail ("Interrupted while sleeping" );
181185 }
182186 };
187+ retainedReferences .add (sleepingSource );
183188 eventDrivenUpdateGraph .addSource (sleepingSource );
184189
185190 final int numConcurrentRefreshes = 10 ;
@@ -199,6 +204,21 @@ public void testRefreshRace() throws ExecutionException, InterruptedException, T
199204 }
200205
201206 Assert .assertEquals (numConcurrentRefreshes , sourceRefreshCount .intValue ());
207+ Assert .assertEquals (sleepingSource , retainedReferences .get (0 ));
208+ }
209+
210+ @ Test
211+ public void testIllegalRefresh () {
212+ final EventDrivenUpdateGraph eventDrivenUpdateGraph = EventDrivenUpdateGraph .newBuilder ("TestEDUG" ).build ();
213+
214+ eventDrivenUpdateGraph .addNotification (new TerminalNotification () {
215+ @ Override
216+ public void run () {
217+ Assert .assertThrows (IllegalStateException .class , eventDrivenUpdateGraph ::requestRefresh );
218+ }
219+ });
220+
221+ eventDrivenUpdateGraph .requestRefresh ();
202222 }
203223
204224 @ Test
0 commit comments