Make sure ImapFolderPusher is not started or stopped twice
This commit is contained in:
parent
01a14b9f1f
commit
b34f3ad669
1 changed files with 13 additions and 10 deletions
|
@ -57,6 +57,10 @@ class ImapFolderPusher extends ImapFolder {
|
|||
|
||||
public void start() {
|
||||
synchronized (threadLock) {
|
||||
if (listeningThread != null) {
|
||||
throw new IllegalStateException("start() called twice");
|
||||
}
|
||||
|
||||
listeningThread = new Thread(new PushRunnable());
|
||||
listeningThread.start();
|
||||
}
|
||||
|
@ -70,9 +74,16 @@ class ImapFolderPusher extends ImapFolder {
|
|||
}
|
||||
|
||||
public void stop() {
|
||||
stop = true;
|
||||
synchronized (threadLock) {
|
||||
if (listeningThread == null) {
|
||||
throw new IllegalStateException("stop() called twice");
|
||||
}
|
||||
|
||||
interruptListeningThread();
|
||||
stop = true;
|
||||
|
||||
listeningThread.interrupt();
|
||||
listeningThread = null;
|
||||
}
|
||||
|
||||
ImapConnection conn = connection;
|
||||
if (conn != null) {
|
||||
|
@ -86,14 +97,6 @@ class ImapFolderPusher extends ImapFolder {
|
|||
}
|
||||
}
|
||||
|
||||
private void interruptListeningThread() {
|
||||
synchronized (threadLock) {
|
||||
if (listeningThread != null) {
|
||||
listeningThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleUntaggedResponse(ImapResponse response) {
|
||||
if (response.getTag() == null && response.size() > 1) {
|
||||
|
|
Loading…
Reference in a new issue