public Object doCommand(IMAPProtocol p) throws ProtocolException { // if the IdleManager is already watching this folder, // there's nothing to do here if (idleState == IDLE && im != null && im == idleManager) return Boolean.TRUE; // already watching it if (idleState == RUNNING) { p.idleStart(); logger.finest("startIdle: set to IDLE"); idleState = IDLE; idleManager = im; return Boolean.TRUE; } else { // some other thread must be running the IDLE // command, we'll just wait for it to finish // without aborting it ourselves try { // give up lock and wait to be not idle messageCacheLock.wait(); } catch (InterruptedException ex) { // restore the interrupted state, which callers // might depend on Thread.currentThread().interrupt(); } return Boolean.FALSE; } } });
@Override public Object doCommand(IMAPProtocol p) throws ProtocolException { // if the IdleManager is already watching this folder, // there's nothing to do here if (idleState == IDLE && im != null && im == idleManager) return Boolean.TRUE; // already watching it if (idleState == RUNNING) { p.idleStart(); logger.finest("startIdle: set to IDLE"); idleState = IDLE; idleManager = im; return Boolean.TRUE; } else { // some other thread must be running the IDLE // command, we'll just wait for it to finish // without aborting it ourselves try { // give up lock and wait to be not idle messageCacheLock.wait(); } catch (InterruptedException ex) { // restore the interrupted state, which callers // might depend on Thread.currentThread().interrupt(); } return Boolean.FALSE; } } });
traceLogger.finest("<EOF>"); throw new EOFException("EOF on socket");
IdleManager im = idleManager; if (im != null) { logger.finest("waitIfIdle: request IdleManager to abort"); im.requestAbort(this); } else { logger.finest("waitIfIdle: abort IDLE"); protocol.idleAbort(); idleState = ABORTING; logger.finest("waitIfIdle: wait to be not idle: " + Thread.currentThread()); messageCacheLock.wait(); if (logger.isLoggable(Level.FINEST)) logger.finest("waitIfIdle: wait done, idleState " + idleState + ": " + Thread.currentThread()); } catch (InterruptedException ex) {
IdleManager im = idleManager; if (im != null) { logger.finest("waitIfIdle: request IdleManager to abort"); im.requestAbort(this); } else { logger.finest("waitIfIdle: abort IDLE"); protocol.idleAbort(); idleState = ABORTING; logger.finest("waitIfIdle: wait to be not idle: " + Thread.currentThread()); messageCacheLock.wait(); if (logger.isLoggable(Level.FINEST)) logger.finest("waitIfIdle: wait done, idleState " + idleState + ": " + Thread.currentThread()); } catch (InterruptedException ex) {
traceLogger.finest("<EOF>"); throw new EOFException("EOF on socket");
if (line.length() == 0) break; logger.finest(line); if (first) { StringTokenizer st = new StringTokenizer(line);
void idleAbortWait() { synchronized (messageCacheLock) { if (idleState == IDLE && protocol != null) { protocol.idleAbort(); idleState = ABORTING; // read responses until OK or connection failure try { for (;;) { if (!handleIdle(false)) break; } } catch (Exception ex) { // assume it's a connection failure; nothing more to do logger.log(Level.FINEST, "Exception in idleAbortWait", ex); } logger.finest("IDLE aborted"); } } }
logger.finest("create socket: prefix " + prefix + ", localaddr " + localaddr + ", localport " + localport + ", host " + host + ", port " + port + logger.finest("set socket read timeout " + to); socket.setSoTimeout(to); if (writeTimeout != -1) { // wrap original if (logger.isLoggable(Level.FINEST)) logger.finest("set socket write timeout " + writeTimeout); socket = new WriteTimeoutSocket(socket, writeTimeout); socket.bind(new InetSocketAddress(localaddr, localport)); try { logger.finest("connecting..."); if (cto >= 0) socket.connect(new InetSocketAddress(host, port), cto); else socket.connect(new InetSocketAddress(host, port)); logger.finest("success!"); } catch (IOException ex) { logger.log(Level.FINEST, "connection failed", ex);
void idleAbortWait() { synchronized (messageCacheLock) { if (idleState == IDLE && protocol != null) { protocol.idleAbort(); idleState = ABORTING; // read responses until OK or connection failure try { for (;;) { if (!handleIdle(false)) break; } } catch (Exception ex) { // assume it's a connection failure; nothing more to do logger.log(Level.FINEST, "Exception in idleAbortWait", ex); } logger.finest("IDLE aborted"); } } }
logger.finest("create socket: prefix " + prefix + ", localaddr " + localaddr + ", localport " + localport + ", host " + host + ", port " + port + logger.finest("set socket read timeout " + to); socket.setSoTimeout(to); if (writeTimeout != -1) { // wrap original if (logger.isLoggable(Level.FINEST)) logger.finest("set socket write timeout " + writeTimeout); socket = new WriteTimeoutSocket(socket, writeTimeout); socket.bind(new InetSocketAddress(localaddr, localport)); try { logger.finest("connecting..."); if (proxyHost != null) proxyConnect(socket, proxyHost, proxyPort, else socket.connect(new InetSocketAddress(host, port)); logger.finest("success!"); } catch (IOException ex) { logger.log(Level.FINEST, "connection failed", ex);
bytesTransferred == 0) { if (ex instanceof SocketTimeoutException) { logger.finest( "handleIdle: ignoring socket timeout"); logger.finest("handleIdle: interrupting IDLE"); IdleManager im = idleManager; if (im != null) { logger.finest( "handleIdle: request IdleManager to abort"); im.requestAbort(this); } else { logger.finest("handleIdle: abort IDLE"); protocol.idleAbort(); idleState = ABORTING; } finally { if (done) { logger.finest("handleIdle: set to RUNNING"); idleState = RUNNING; idleManager = null;
bytesTransferred == 0) { if (ex instanceof SocketTimeoutException) { logger.finest( "handleIdle: ignoring socket timeout"); logger.finest("handleIdle: interrupting IDLE"); IdleManager im = idleManager; if (im != null) { logger.finest( "handleIdle: request IdleManager to abort"); im.requestAbort(this); } else { logger.finest("handleIdle: abort IDLE"); protocol.idleAbort(); idleState = ABORTING; } finally { if (done) { logger.finest("handleIdle: set to RUNNING"); idleState = RUNNING; idleManager = null;
logger.finest("IdleManager requesting DONE with timeout"); toWatch.remove(folder); final IMAPFolder folder0 = folder;
logger.finest("IdleManager requesting DONE with timeout"); toWatch.remove(folder); final IMAPFolder folder0 = folder;
if (to >= 0) { if (logger.isLoggable(Level.FINEST)) logger.finest("set socket read timeout " + to); socket.setSoTimeout(to);