445 if (!(t instanceof SecurityException)) {
446 try {
447 TCPEndpoint.shedConnectionCaches();
448 } catch (Throwable tt) {
449 }
450 }
451
452 /*
453 * A NoClassDefFoundError can occur if no file
454 * descriptors are available, in which case this
455 * loop should not terminate.
456 */
457 if (t instanceof Exception ||
458 t instanceof OutOfMemoryError ||
459 t instanceof NoClassDefFoundError)
460 {
461 if (!continueAfterAcceptFailure(t)) {
462 return;
463 }
464 // continue loop
465 } else {
466 throw (Error) t;
467 }
468 }
469 }
470 }
471
472 /**
473 * Returns true if the accept loop should continue after the
474 * specified exception has been caught, or false if the accept
475 * loop should terminate (closing the server socket). If
476 * there is an RMIFailureHandler, this method returns the
477 * result of passing the specified exception to it; otherwise,
478 * this method always returns true, after sleeping to throttle
479 * the accept loop if necessary.
480 **/
481 private boolean continueAfterAcceptFailure(Throwable t) {
482 RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
483 if (fh != null) {
484 return fh.failure(t instanceof Exception ? (Exception) t :
485 new InvocationTargetException(t));
486 } else {
|
445 if (!(t instanceof SecurityException)) {
446 try {
447 TCPEndpoint.shedConnectionCaches();
448 } catch (Throwable tt) {
449 }
450 }
451
452 /*
453 * A NoClassDefFoundError can occur if no file
454 * descriptors are available, in which case this
455 * loop should not terminate.
456 */
457 if (t instanceof Exception ||
458 t instanceof OutOfMemoryError ||
459 t instanceof NoClassDefFoundError)
460 {
461 if (!continueAfterAcceptFailure(t)) {
462 return;
463 }
464 // continue loop
465 } else if (t instanceof Error) {
466 throw (Error) t;
467 } else {
468 throw new Error(t.getMessage(), t.getCause());
469 }
470 }
471 }
472 }
473
474 /**
475 * Returns true if the accept loop should continue after the
476 * specified exception has been caught, or false if the accept
477 * loop should terminate (closing the server socket). If
478 * there is an RMIFailureHandler, this method returns the
479 * result of passing the specified exception to it; otherwise,
480 * this method always returns true, after sleeping to throttle
481 * the accept loop if necessary.
482 **/
483 private boolean continueAfterAcceptFailure(Throwable t) {
484 RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
485 if (fh != null) {
486 return fh.failure(t instanceof Exception ? (Exception) t :
487 new InvocationTargetException(t));
488 } else {
|