Skip to content
This repository has been archived by the owner on Mar 6, 2018. It is now read-only.

Fix for IllegalStateException: Timer was canceled #44

Open
downtownallday opened this issue Mar 11, 2013 · 2 comments
Open

Fix for IllegalStateException: Timer was canceled #44

downtownallday opened this issue Mar 11, 2013 · 2 comments

Comments

@downtownallday
Copy link

Apparently cleanup() is called before transportDisconnected() and the second cleanup() call from reconnect() throws the exception. Also, you can't call disconnect() in onError(), or that will also cause a problem (and you don't need to). Hopefully, this will fix the issue:

diff --git "a/C:\\Users\\WxAp\\AppData\\Local\\Temp\\TortoiseGit\\IOCDCF7.tmp\\IOConnection-8f4c6b7-left.java" "b/C:\\ExternalLibs\\sources\\socket.io-java-client\\src\\io\\socket\\IOConnection.java"
index 420d0cc..3dc207b 100644
--- "a/C:\\Users\\WxAp\\AppData\\Local\\Temp\\TortoiseGit\\IOCDCF7.tmp\\IOConnection-8f4c6b7-left.java"
+++ "b/C:\\ExternalLibs\\sources\\socket.io-java-client\\src\\io\\socket\\IOConnection.java"
@@ -555,7 +555,7 @@ class IOConnection implements IOCallback {
     */
    public void transportDisconnected() {
        this.lastException = null;
-       setState(STATE_INTERRUPTED);
+       if (getState() != STATE_INVALID) setState(STATE_INTERRUPTED);
        reconnect();
    }

@@ -568,7 +568,7 @@ class IOConnection implements IOCallback {
     */
    public void transportError(Exception error) {
        this.lastException = error;
-       setState(STATE_INTERRUPTED);
+       if (getState() != STATE_INVALID) setState(STATE_INTERRUPTED);
        reconnect();
    }
@qiankanglai
Copy link

WOW! It works!!!
Thank you very much!!!

This puzzles me whole night (http://stackoverflow.com/questions/15642784/thread-sleep-cause-exception-in-jmeter-java-request)
You saved me a lot of time

@daniel-brettschneider
Copy link

This fixes the exception but now there is a thread or something that does not get cancelled and my app does not exit.

Gottox pushed a commit that referenced this issue Apr 9, 2013
fatshotty added a commit to fatshotty/socket.io-java-client that referenced this issue Apr 10, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants