MCPcopy Create free account
hub / github.com/M66B/FairEmail / waitIfIdle

Method waitIfIdle

app/src/main/java/com/sun/mail/imap/IMAPFolder.java:3377–3412  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3375 * ASSERT: Must be called with the message cache lock held.
3376 */
3377 void waitIfIdle() throws ProtocolException {
3378 assert Thread.holdsLock(messageCacheLock);
3379 while (idleState != RUNNING) {
3380 if (idleState == IDLE) {
3381 IdleManager im = idleManager;
3382 if (im != null) {
3383 logger.finest("waitIfIdle: request IdleManager to abort");
3384 im.requestAbort(this);
3385 } else {
3386 logger.finest("waitIfIdle: abort IDLE");
3387 protocol.idleAbort();
3388 idleState = ABORTING;
3389 }
3390 } else
3391 logger.log(Level.FINEST, "waitIfIdle: idleState {0}", idleState);
3392 try {
3393 // give up lock and wait to be not idle
3394 if (logger.isLoggable(Level.FINEST))
3395 logger.finest("waitIfIdle: wait to be not idle: " +
3396 Thread.currentThread());
3397 messageCacheLock.wait();
3398 if (logger.isLoggable(Level.FINEST))
3399 logger.finest("waitIfIdle: wait done, idleState " +
3400 idleState + ": " + Thread.currentThread());
3401 } catch (InterruptedException ex) {
3402 // restore the interrupted state, which callers might depend on
3403 Thread.currentThread().interrupt();
3404 // If someone is trying to interrupt us we can't keep going
3405 // around the loop waiting for IDLE to complete, but we can't
3406 // just return because callers expect the idleState to be
3407 // RUNNING when we return. Throwing this exception seems
3408 // like the best choice.
3409 throw new ProtocolException("Interrupted waitIfIdle", ex);
3410 }
3411 }
3412 }
3413
3414 /*
3415 * Send the DONE command that aborts the IDLE; used by IdleManager.

Callers 3

closeMethod · 0.95
getProtocolMethod · 0.95
keepConnectionAliveMethod · 0.95

Calls 5

requestAbortMethod · 0.95
finestMethod · 0.80
idleAbortMethod · 0.45
logMethod · 0.45
isLoggableMethod · 0.45

Tested by

no test coverage detected