{"action":"opened","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/7611","repository_url":"https://api.github.com/repos/hazelcast/hazelcast","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/7611/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/7611/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/7611/events","html_url":"https://github.com/hazelcast/hazelcast/issues/7611","id":136450963,"number":7611,"title":"ScheduledExecutorServiceDelegate violates contracts of ScheduledExecutorService","user":{"login":"jerrinot","id":158619,"avatar_url":"https://avatars.githubusercontent.com/u/158619?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrinot","html_url":"https://github.com/jerrinot","followers_url":"https://api.github.com/users/jerrinot/followers","following_url":"https://api.github.com/users/jerrinot/following{/other_user}","gists_url":"https://api.github.com/users/jerrinot/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrinot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrinot/subscriptions","organizations_url":"https://api.github.com/users/jerrinot/orgs","repos_url":"https://api.github.com/users/jerrinot/repos","events_url":"https://api.github.com/users/jerrinot/events{/privacy}","received_events_url":"https://api.github.com/users/jerrinot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Core","name":"Team: Core","color":"109def"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Type:%20Defect","name":"Type: Defect","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/70","html_url":"https://github.com/hazelcast/hazelcast/milestones/3.7","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/70/labels","id":1346433,"number":70,"title":"3.7","description":"","creator":{"login":"pveentjer","id":105243,"avatar_url":"https://avatars.githubusercontent.com/u/105243?v=3","gravatar_id":"","url":"https://api.github.com/users/pveentjer","html_url":"https://github.com/pveentjer","followers_url":"https://api.github.com/users/pveentjer/followers","following_url":"https://api.github.com/users/pveentjer/following{/other_user}","gists_url":"https://api.github.com/users/pveentjer/gists{/gist_id}","starred_url":"https://api.github.com/users/pveentjer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pveentjer/subscriptions","organizations_url":"https://api.github.com/users/pveentjer/orgs","repos_url":"https://api.github.com/users/pveentjer/repos","events_url":"https://api.github.com/users/pveentjer/events{/privacy}","received_events_url":"https://api.github.com/users/pveentjer/received_events","type":"User","site_admin":false},"open_issues":185,"closed_issues":119,"state":"open","created_at":"2015-10-09T12:16:13Z","updated_at":"2016-02-25T17:14:41Z","due_on":"2016-02-29T22:00:00Z","closed_at":null},"comments":0,"created_at":"2016-02-25T17:14:41Z","updated_at":"2016-02-25T17:14:41Z","closed_at":null,"body":"Contract of `scheduleAtFixedRate` says: \r\n```\r\n     * If any execution of this task\r\n     * takes longer than its period, then subsequent executions\r\n     * may start late, but **will not concurrently execute**.\r\n```\r\n\r\nHowever the `ScheduledExecutorServiceDelegate` wraps tasks in `ScheduledTaskRunner` which delegates to a different executor. As a consequence a task can be executed concurrently thus a contract of `ScheduledExecutorService` is violated. \r\n\r\nThis leads to surprises. this was seen in a testing environment: \r\n```java\r\nException in thread \"cached4\" java.lang.IllegalArgumentException: Comparison method violates its general contract!\r\n    at java.util.TimSort.mergeHi(TimSort.java:895)\r\n    at java.util.TimSort.mergeAt(TimSort.java:512)\r\n    at java.util.TimSort.mergeCollapse(TimSort.java:437)\r\n    at java.util.TimSort.sort(TimSort.java:241)\r\n    at java.util.Arrays.sort(Arrays.java:1512)\r\n    at java.util.ArrayList.sort(ArrayList.java:1454)\r\n    at java.util.Collections.sort(Collections.java:175)\r\n    at com.hazelcast.map.impl.eviction.ExpirationManager$ClearExpiredRecordsTask.sortPartitionContainers(ExpirationManager.java:127)\r\n    at com.hazelcast.map.impl.eviction.ExpirationManager$ClearExpiredRecordsTask.run(ExpirationManager.java:121)\r\n    at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:212)\r\n    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n    at java.lang.Thread.run(Thread.java:745)\r\n    at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)\r\n    at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)\r\n```"}}