{"action":"created","issue":{"url":"https://api.github.com/repos/hierynomus/sshj/issues/283","repository_url":"https://api.github.com/repos/hierynomus/sshj","labels_url":"https://api.github.com/repos/hierynomus/sshj/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/hierynomus/sshj/issues/283/comments","events_url":"https://api.github.com/repos/hierynomus/sshj/issues/283/events","html_url":"https://github.com/hierynomus/sshj/issues/283","id":192291364,"number":283,"title":"Keepalive thread's  interrupt signal may be catched when it is sleeping","user":{"login":"gatesking","id":6533273,"avatar_url":"https://avatars.githubusercontent.com/u/6533273?v=3","gravatar_id":"","url":"https://api.github.com/users/gatesking","html_url":"https://github.com/gatesking","followers_url":"https://api.github.com/users/gatesking/followers","following_url":"https://api.github.com/users/gatesking/following{/other_user}","gists_url":"https://api.github.com/users/gatesking/gists{/gist_id}","starred_url":"https://api.github.com/users/gatesking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gatesking/subscriptions","organizations_url":"https://api.github.com/users/gatesking/orgs","repos_url":"https://api.github.com/users/gatesking/repos","events_url":"https://api.github.com/users/gatesking/events{/privacy}","received_events_url":"https://api.github.com/users/gatesking/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-29T14:09:41Z","updated_at":"2016-11-30T08:42:50Z","closed_at":"2016-11-30T08:42:50Z","body":"In Keepalive.java:\r\n```\r\ntry {\r\n            while (!isInterrupted()) {\r\n                final int hi = getPositiveInterval();\r\n                if (conn.getTransport().isRunning()) {\r\n                    log.debug(\"Sending keep-alive since {} seconds elapsed\", hi);\r\n                    doKeepAlive();\r\n                }\r\n                **Thread.sleep(hi * 1000);**\r\n            }\r\n        } catch (Exception e) {\r\n            // If we weren't interrupted, kill the transport, then this exception was unexpected.\r\n            // Else we're in shutdown-mode already, so don't forcibly kill the transport.\r\n            if (!isInterrupted()) {\r\n                conn.getTransport().die(e);\r\n            }\r\n        }\r\n```\r\nwhen keepalive interrupt is called in ConnectionImpl.notifyError, the interrupt signal may be catched by Thread.sleep, as a result, it will still go into conn.getTransport().die(e).\r\nI suggest catch interrupt signal will be better, am I right?\r\n```\r\ntry {\r\n            while (!isInterrupted()) {\r\n                final int hi = getPositiveInterval();\r\n                if (conn.getTransport().isRunning()) {\r\n                    log.debug(\"Sending keep-alive since {} seconds elapsed\", hi);\r\n                    doKeepAlive();\r\n                }\r\n                Thread.sleep(hi * 1000);\r\n            }\r\n        } **catch (InterruptedException e) {\r\n                // do nothing\r\n        }** catch (Exception e) {\r\n            // If we weren't interrupted, kill the transport, then this exception was unexpected.\r\n            // Else we're in shutdown-mode already, so don't forcibly kill the transport.\r\n            if (!isInterrupted()) {\r\n                conn.getTransport().die(e);\r\n            }\r\n        }\r\n```\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/hierynomus/sshj/issues/comments/263815316","html_url":"https://github.com/hierynomus/sshj/issues/283#issuecomment-263815316","issue_url":"https://api.github.com/repos/hierynomus/sshj/issues/283","id":263815316,"user":{"login":"hierynomus","id":117667,"avatar_url":"https://avatars.githubusercontent.com/u/117667?v=3","gravatar_id":"","url":"https://api.github.com/users/hierynomus","html_url":"https://github.com/hierynomus","followers_url":"https://api.github.com/users/hierynomus/followers","following_url":"https://api.github.com/users/hierynomus/following{/other_user}","gists_url":"https://api.github.com/users/hierynomus/gists{/gist_id}","starred_url":"https://api.github.com/users/hierynomus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hierynomus/subscriptions","organizations_url":"https://api.github.com/users/hierynomus/orgs","repos_url":"https://api.github.com/users/hierynomus/repos","events_url":"https://api.github.com/users/hierynomus/events{/privacy}","received_events_url":"https://api.github.com/users/hierynomus/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T08:42:50Z","updated_at":"2016-11-30T08:42:50Z","body":"Merged #284, thanks!"}}
{"actor":{"display_login":"hierynomus"}}