{"action":"created","issue":{"url":"https://api.github.com/repos/novoda/download-manager/issues/380","repository_url":"https://api.github.com/repos/novoda/download-manager","labels_url":"https://api.github.com/repos/novoda/download-manager/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/novoda/download-manager/issues/380/comments","events_url":"https://api.github.com/repos/novoda/download-manager/issues/380/events","html_url":"https://github.com/novoda/download-manager/issues/380","id":309754364,"number":380,"title":"Possible race condition in `ThenPerform`","user":{"login":"aclassen","id":5637262,"avatar_url":"https://avatars2.githubusercontent.com/u/5637262?v=4","gravatar_id":"","url":"https://api.github.com/users/aclassen","html_url":"https://github.com/aclassen","followers_url":"https://api.github.com/users/aclassen/followers","following_url":"https://api.github.com/users/aclassen/following{/other_user}","gists_url":"https://api.github.com/users/aclassen/gists{/gist_id}","starred_url":"https://api.github.com/users/aclassen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aclassen/subscriptions","organizations_url":"https://api.github.com/users/aclassen/orgs","repos_url":"https://api.github.com/users/aclassen/repos","events_url":"https://api.github.com/users/aclassen/events{/privacy}","received_events_url":"https://api.github.com/users/aclassen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-29T13:27:36Z","updated_at":"2018-04-20T14:58:57Z","closed_at":null,"author_association":"NONE","body":"There 's a possible race condition between `waitForLock` in `ThenPerform` and `DownloadManager` `waitForDownloadService.notifyAll();`\r\n\r\nIf an instance of  `ThenPerform` is created with a `null` DownloadService and `notifyAll` is called before `waitForLock` is called.\r\n\r\nIn case the Single Thread Executor is used like : `executor.submit(() -> Wait.<Void>waitFor(downloadService, waitForDownloadService)`\r\n\r\nthe executor is deadlocked."},"comment":{"url":"https://api.github.com/repos/novoda/download-manager/issues/comments/383123998","html_url":"https://github.com/novoda/download-manager/issues/380#issuecomment-383123998","issue_url":"https://api.github.com/repos/novoda/download-manager/issues/380","id":383123998,"user":{"login":"zegnus","id":2845931,"avatar_url":"https://avatars3.githubusercontent.com/u/2845931?v=4","gravatar_id":"","url":"https://api.github.com/users/zegnus","html_url":"https://github.com/zegnus","followers_url":"https://api.github.com/users/zegnus/followers","following_url":"https://api.github.com/users/zegnus/following{/other_user}","gists_url":"https://api.github.com/users/zegnus/gists{/gist_id}","starred_url":"https://api.github.com/users/zegnus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zegnus/subscriptions","organizations_url":"https://api.github.com/users/zegnus/orgs","repos_url":"https://api.github.com/users/zegnus/repos","events_url":"https://api.github.com/users/zegnus/events{/privacy}","received_events_url":"https://api.github.com/users/zegnus/received_events","type":"User","site_admin":false},"created_at":"2018-04-20T14:58:57Z","updated_at":"2018-04-20T14:58:57Z","author_association":"CONTRIBUTOR","body":"Hey @aclassen thank you for your feedback. Looking at the code I found this race condition highly unlikely.\r\n\r\nFor a deadlock to happen something like this must happen:\r\n1. `DownloadManager.getAllDownloadBatchStatuses()` null instance, `waitForLock` is about to be executed\r\n2. `DownloadManager.initialise()` is called, `notifyAll` that's on a `synchronized` block is about to be called\r\n\r\nOnly if the `waitForLock` and `notifyAll` methods are swapped at execution time we'll have a deadlock but I don't think that this is a realistic scenario.\r\n\r\nHave you been able to reproduce this issue? Do you have any suggestions?"}}
{"actor":{"display_login":"zegnus"}}