@@ -274,6 +274,22 @@ private void configureRanges(ReadTableSettings.Builder rtsb) {
274274 }
275275 }
276276
277+ private void putToQueue (QueueItem qi ) {
278+ while (true ) {
279+ try {
280+ queue .add (qi );
281+ break ; // exit the "queue put" retry loop
282+ } catch (IllegalStateException ise ) {
283+ // The unlikely case of thread interrupt should not prevent us
284+ // from putting an item into the queue
285+ try {
286+ Thread .sleep (35L );
287+ } catch (InterruptedException ix ) {
288+ }
289+ }
290+ }
291+ }
292+
277293 static final class QueueItem {
278294
279295 final ResultSetReader reader ;
@@ -298,21 +314,9 @@ public void run() {
298314 try {
299315 stream .start (part -> {
300316 final ResultSetReader rsr = part .getResultSetReader ();
301- while (true ) {
302- try {
303- queue .add (new QueueItem (rsr ));
304- LOG .debug ("Added portion of {} rows for table {} to the queue." ,
305- rsr .getRowCount (), tablePath );
306- return ; // exit the "queue put" retry loop - and lambda too
307- } catch (IllegalStateException ise ) {
308- // The unlikely case of interrupt should not prevent us
309- // from putting an item into the queue
310- try {
311- Thread .sleep (35L );
312- } catch (InterruptedException ix ) {
313- }
314- }
315- }
317+ putToQueue (new QueueItem (rsr ));
318+ LOG .debug ("Added portion of {} rows for table {} to the queue." ,
319+ rsr .getRowCount (), tablePath );
316320 }).join ().expectSuccess ();
317321 } catch (Exception ex ) {
318322 boolean needReport = true ;
@@ -327,7 +331,7 @@ public void run() {
327331 setIssue (ex );
328332 }
329333 }
330- queue . add (END_OF_SCAN );
334+ putToQueue (END_OF_SCAN );
331335 LOG .debug ("Completed background scan for table {}, range {}" , tablePath , keyRange );
332336 }
333337 }
0 commit comments