{"action":"created","issue":{"url":"https://api.github.com/repos/dropwizard/metrics/issues/515","labels_url":"https://api.github.com/repos/dropwizard/metrics/issues/515/labels{/name}","comments_url":"https://api.github.com/repos/dropwizard/metrics/issues/515/comments","events_url":"https://api.github.com/repos/dropwizard/metrics/issues/515/events","html_url":"https://github.com/dropwizard/metrics/issues/515","id":25710058,"number":515,"title":"SlidingTimeWindowReservoir getTick() can overflow and break","user":{"login":"omerkudat","id":1287880,"avatar_url":"https://avatars.githubusercontent.com/u/1287880?v=3","gravatar_id":"","url":"https://api.github.com/users/omerkudat","html_url":"https://github.com/omerkudat","followers_url":"https://api.github.com/users/omerkudat/followers","following_url":"https://api.github.com/users/omerkudat/following{/other_user}","gists_url":"https://api.github.com/users/omerkudat/gists{/gist_id}","starred_url":"https://api.github.com/users/omerkudat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omerkudat/subscriptions","organizations_url":"https://api.github.com/users/omerkudat/orgs","repos_url":"https://api.github.com/users/omerkudat/repos","events_url":"https://api.github.com/users/omerkudat/events{/privacy}","received_events_url":"https://api.github.com/users/omerkudat/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dropwizard/metrics/labels/bug","name":"bug","color":"e10c02"}],"state":"open","locked":false,"assignee":{"login":"ryantenney","id":124015,"avatar_url":"https://avatars.githubusercontent.com/u/124015?v=3","gravatar_id":"","url":"https://api.github.com/users/ryantenney","html_url":"https://github.com/ryantenney","followers_url":"https://api.github.com/users/ryantenney/followers","following_url":"https://api.github.com/users/ryantenney/following{/other_user}","gists_url":"https://api.github.com/users/ryantenney/gists{/gist_id}","starred_url":"https://api.github.com/users/ryantenney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryantenney/subscriptions","organizations_url":"https://api.github.com/users/ryantenney/orgs","repos_url":"https://api.github.com/users/ryantenney/repos","events_url":"https://api.github.com/users/ryantenney/events{/privacy}","received_events_url":"https://api.github.com/users/ryantenney/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dropwizard/metrics/milestones/11","html_url":"https://github.com/dropwizard/metrics/milestones/4.0.0","labels_url":"https://api.github.com/repos/dropwizard/metrics/milestones/11/labels","id":613729,"number":11,"title":"4.0.0","description":null,"creator":{"login":"ryantenney","id":124015,"avatar_url":"https://avatars.githubusercontent.com/u/124015?v=3","gravatar_id":"","url":"https://api.github.com/users/ryantenney","html_url":"https://github.com/ryantenney","followers_url":"https://api.github.com/users/ryantenney/followers","following_url":"https://api.github.com/users/ryantenney/following{/other_user}","gists_url":"https://api.github.com/users/ryantenney/gists{/gist_id}","starred_url":"https://api.github.com/users/ryantenney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryantenney/subscriptions","organizations_url":"https://api.github.com/users/ryantenney/orgs","repos_url":"https://api.github.com/users/ryantenney/repos","events_url":"https://api.github.com/users/ryantenney/events{/privacy}","received_events_url":"https://api.github.com/users/ryantenney/received_events","type":"User","site_admin":false},"open_issues":18,"closed_issues":3,"state":"open","created_at":"2014-03-28T23:28:12Z","updated_at":"2015-06-19T15:08:11Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2014-01-16T08:39:17Z","updated_at":"2015-06-21T03:54:23Z","closed_at":null,"body":"The getTick() function of SlidingTimeWindowReservoir uses a collision buffer to allow for measurements which are happening within the same \"tick\". The default Clock tick is provided by System.nanoTime().\r\n\r\nUnder certain circumstances, nanoTime() returns a long sufficiently large that when multiplied by the collision buffer, it overflow into a negative number. The next line in the function will then check whether the new tick (nanos * buffer) is larger than the old and, if not, it will return oldTick + 1. Because of this, the getTick() function returns ticks which are always incresing by one, therefore distorting the window.\r\n\r\nTo fix this, I added an absolute offset value to the class. The offset value can be a final field which is initialized when the class is constructured or a static. Following each call to Clock.getTick(), we would reduce the return value but this absolute amount."},"comment":{"url":"https://api.github.com/repos/dropwizard/metrics/issues/comments/113861780","html_url":"https://github.com/dropwizard/metrics/issues/515#issuecomment-113861780","issue_url":"https://api.github.com/repos/dropwizard/metrics/issues/515","id":113861780,"user":{"login":"ryantenney","id":124015,"avatar_url":"https://avatars.githubusercontent.com/u/124015?v=3","gravatar_id":"","url":"https://api.github.com/users/ryantenney","html_url":"https://github.com/ryantenney","followers_url":"https://api.github.com/users/ryantenney/followers","following_url":"https://api.github.com/users/ryantenney/following{/other_user}","gists_url":"https://api.github.com/users/ryantenney/gists{/gist_id}","starred_url":"https://api.github.com/users/ryantenney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryantenney/subscriptions","organizations_url":"https://api.github.com/users/ryantenney/orgs","repos_url":"https://api.github.com/users/ryantenney/repos","events_url":"https://api.github.com/users/ryantenney/events{/privacy}","received_events_url":"https://api.github.com/users/ryantenney/received_events","type":"User","site_admin":false},"created_at":"2015-06-21T03:54:23Z","updated_at":"2015-06-21T03:54:23Z","body":"@victor-prp I've just committed a possible fix, as well as your test: d49489663c43aa29593a363a08d2dbb7dd2e3582, however the test now times out, instead of resulting in an assertion error."}}