use of i2p.bote.fileencryption.PasswordException in project i2p.i2p-bote by i2p.
the class OutboxProcessor method run.
@Override
public void run() {
while (!Thread.interrupted()) {
try {
synchronized (this) {
wakeupSignal = new CountDownLatch(1);
}
if (networkStatusSource.isConnected()) {
log.debug("Processing outgoing emails in directory '" + outbox.getStorageDirectory() + "'.");
FolderIterator<Email> iterator = outbox.iterate();
try {
while (iterator.hasNext()) {
Email email = iterator.next();
log.info("Processing email with message Id: '" + email.getMessageID() + "'.");
// signature flag only makes sense locally
email.removeSignatureFlag();
try {
sendEmail(email);
fireOutboxListeners(email);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
} catch (Exception e) {
log.error("Error sending email.", e);
}
}
} catch (PasswordException e) {
log.debug("Can't scan outbox because a password is set and the application is locked.");
}
}
int pause = configuration.getOutboxCheckInterval();
wakeupSignal.await(pause, TimeUnit.MINUTES);
} catch (InterruptedException e) {
break;
} catch (RuntimeException e) {
// catch unexpected exceptions to keep the thread running
log.error("Exception caught in OutboxProcessor loop", e);
}
}
log.debug("OutboxProcessor thread exiting.");
}
Aggregations