{"action":"created","issue":{"url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/85","labels_url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/85/labels{/name}","comments_url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/85/comments","events_url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/85/events","html_url":"https://github.com/RuedigerMoeller/fast-serialization/issues/85","id":105458034,"number":85,"title":"BinaryQueue does not work correctly","user":{"login":"int999","id":2975867,"avatar_url":"https://avatars.githubusercontent.com/u/2975867?v=3","gravatar_id":"","url":"https://api.github.com/users/int999","html_url":"https://github.com/int999","followers_url":"https://api.github.com/users/int999/followers","following_url":"https://api.github.com/users/int999/following{/other_user}","gists_url":"https://api.github.com/users/int999/gists{/gist_id}","starred_url":"https://api.github.com/users/int999/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/int999/subscriptions","organizations_url":"https://api.github.com/users/int999/orgs","repos_url":"https://api.github.com/users/int999/repos","events_url":"https://api.github.com/users/int999/events{/privacy}","received_events_url":"https://api.github.com/users/int999/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-08T19:59:48Z","updated_at":"2015-09-08T22:49:51Z","closed_at":null,"body":"The following code reproduces the problem : \r\n\r\n```Java\r\nimport org.nustaq.offheap.BinaryQueue;\r\n\r\npublic class TestQ {\r\n    public static void main(String s[]) {\t\t\r\n\t\t\r\n\t\tBinaryQueue bq = new BinaryQueue(3);\r\n\t\tbq.add((byte)1);\r\n\t\tbq.add((byte)2);\r\n\t\tbq.add((byte)3);\r\n\t\tbq.add((byte)4);\r\n    \t\t\t\r\n\t\tfor (int i = 0; i < 4; i++) {\r\n\t\t\tSystem.out.println(bq.poll());\r\n\t\t}\r\n\t}\r\n}\r\n\r\nOutput : \r\n\r\n4\r\n-1\r\n-1\r\n-1\r\n\r\n```\r\n\r\nIt seems the problem is that when the third byte is added, the code \r\n\r\n```\r\nif ( addIndex >= storage.length() )\r\n            addIndex -= storage.length();\r\n```\r\n\r\nin the BinaryQueue's add() method sets the addIndex to 0, and then when the fourth byte is added the remaining() method returns 3, when it should return 0."},"comment":{"url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/comments/138725011","html_url":"https://github.com/RuedigerMoeller/fast-serialization/issues/85#issuecomment-138725011","issue_url":"https://api.github.com/repos/RuedigerMoeller/fast-serialization/issues/85","id":138725011,"user":{"login":"RuedigerMoeller","id":6097932,"avatar_url":"https://avatars.githubusercontent.com/u/6097932?v=3","gravatar_id":"","url":"https://api.github.com/users/RuedigerMoeller","html_url":"https://github.com/RuedigerMoeller","followers_url":"https://api.github.com/users/RuedigerMoeller/followers","following_url":"https://api.github.com/users/RuedigerMoeller/following{/other_user}","gists_url":"https://api.github.com/users/RuedigerMoeller/gists{/gist_id}","starred_url":"https://api.github.com/users/RuedigerMoeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuedigerMoeller/subscriptions","organizations_url":"https://api.github.com/users/RuedigerMoeller/orgs","repos_url":"https://api.github.com/users/RuedigerMoeller/repos","events_url":"https://api.github.com/users/RuedigerMoeller/events{/privacy}","received_events_url":"https://api.github.com/users/RuedigerMoeller/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T22:49:51Z","updated_at":"2015-09-08T22:49:51Z","body":"actually auto-grow should be triggered in your test case"}}