@@ -430,38 +430,31 @@ public void actionPerformed(NetworkEvent e) {
430430 public void addToQueueAndWait (final ConnectionRequest request ) {
431431 class WaitingClass implements Runnable , ActionListener <NetworkEvent > {
432432 private final boolean edt = CN .isEdt ();
433-
434- private boolean isInQueueOrProcessing () {
435- synchronized (LOCK ) {
436- if (pending == null || networkThreads == null ) {
437- return false ;
438- }
439- if (pending .contains (request )) {
440- return true ;
441- }
442- for (NetworkThread t : networkThreads ) {
443- if (t .currentRequest == request ) {
444- return true ;
445- }
446- }
447- }
448- return false ;
449- }
433+ private boolean finishedWaiting ;
450434
451435 public void run () {
452436 if (edt ) {
453- while (isInQueueOrProcessing ()) {
454- Util .sleep (30 );
437+ while (!finishedWaiting ) {
438+ try {
439+ Thread .sleep (30 );
440+ } catch (InterruptedException ex ) {
441+ ex .printStackTrace ();
442+ }
455443 }
456444 } else {
457- while (isInQueueOrProcessing ()) {
458- Util .sleep (30 );
445+ while (!request .complete ) {
446+ try {
447+ Thread .sleep (30 );
448+ } catch (InterruptedException ex ) {
449+ ex .printStackTrace ();
450+ }
459451 }
460452 }
461453 }
462454
463455 public void actionPerformed (NetworkEvent e ) {
464456 if (e .getError () != null ) {
457+ finishedWaiting = true ;
465458 removeProgressListener (this );
466459 removeErrorListener (this );
467460 return ;
@@ -472,6 +465,7 @@ public void actionPerformed(NetworkEvent e) {
472465 request .retrying = false ;
473466 return ;
474467 }
468+ finishedWaiting = true ;
475469 removeProgressListener (this );
476470 removeErrorListener (this );
477471 }
0 commit comments