{"action":"created","comment":{"url":"https://api.github.com/repos/samtools/htsjdk/pulls/comments/223085627","pull_request_review_id":162135083,"id":223085627,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzA4NTYyNw==","diff_hunk":"@@ -415,7 +415,8 @@ public int readBytesOrFewer(final byte[] buffer, final int offset, final int len\n             throw new IllegalStateException(\"Calling read method on BinaryCodec open for write.\");\r\n         }\r\n         try {\r\n-            return inputStream.read(buffer, offset, length);\r\n+            if (length == 0) return 0;\r","path":"src/main/java/htsjdk/samtools/util/BinaryCodec.java","position":5,"original_position":5,"commit_id":"6d40e0a8b458edcd2dc7a2fa58d6f4dbc61f7310","original_commit_id":"6d40e0a8b458edcd2dc7a2fa58d6f4dbc61f7310","user":{"login":"pshapiro4broad","id":1799360,"node_id":"MDQ6VXNlcjE3OTkzNjA=","avatar_url":"https://avatars2.githubusercontent.com/u/1799360?v=4","gravatar_id":"","url":"https://api.github.com/users/pshapiro4broad","html_url":"https://github.com/pshapiro4broad","followers_url":"https://api.github.com/users/pshapiro4broad/followers","following_url":"https://api.github.com/users/pshapiro4broad/following{/other_user}","gists_url":"https://api.github.com/users/pshapiro4broad/gists{/gist_id}","starred_url":"https://api.github.com/users/pshapiro4broad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pshapiro4broad/subscriptions","organizations_url":"https://api.github.com/users/pshapiro4broad/orgs","repos_url":"https://api.github.com/users/pshapiro4broad/repos","events_url":"https://api.github.com/users/pshapiro4broad/events{/privacy}","received_events_url":"https://api.github.com/users/pshapiro4broad/received_events","type":"User","site_admin":false},"body":"use `{` `}` around `if` body","created_at":"2018-10-05T17:35:49Z","updated_at":"2018-10-05T17:35:49Z","html_url":"https://github.com/samtools/htsjdk/pull/1188#discussion_r223085627","pull_request_url":"https://api.github.com/repos/samtools/htsjdk/pulls/1188","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/comments/223085627"},"html":{"href":"https://github.com/samtools/htsjdk/pull/1188#discussion_r223085627"},"pull_request":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/1188"}}},"pull_request":{"url":"https://api.github.com/repos/samtools/htsjdk/pulls/1188","id":220769863,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNzY5ODYz","html_url":"https://github.com/samtools/htsjdk/pull/1188","diff_url":"https://github.com/samtools/htsjdk/pull/1188.diff","patch_url":"https://github.com/samtools/htsjdk/pull/1188.patch","issue_url":"https://api.github.com/repos/samtools/htsjdk/issues/1188","number":1188,"state":"open","locked":false,"title":"BinaryCodec.readBytesOrFewer fails if no data is requested AND no date is available in the underlying input stream","user":{"login":"nh13","id":846274,"node_id":"MDQ6VXNlcjg0NjI3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/846274?v=4","gravatar_id":"","url":"https://api.github.com/users/nh13","html_url":"https://github.com/nh13","followers_url":"https://api.github.com/users/nh13/followers","following_url":"https://api.github.com/users/nh13/following{/other_user}","gists_url":"https://api.github.com/users/nh13/gists{/gist_id}","starred_url":"https://api.github.com/users/nh13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nh13/subscriptions","organizations_url":"https://api.github.com/users/nh13/orgs","repos_url":"https://api.github.com/users/nh13/repos","events_url":"https://api.github.com/users/nh13/events{/privacy}","received_events_url":"https://api.github.com/users/nh13/received_events","type":"User","site_admin":false},"body":"I ran into this bug when writing an empty string as the last element into a byte buffer (ex `binaryCodec.writeString(\"\", true, false)`) and then trying to read it back in (ex. `binaryCodec.readLengthAndString(false)`).  The main issue is that `InputStream.read` will return `-1` even if the maximum number of bytes to read is zero (i.e. `InputStream.read(buffer, 0, 0)` will return `-1`).\r\n\r\nI made a commit with a test to show the bug and a commit to fix it.\r\n","created_at":"2018-10-05T17:19:23Z","updated_at":"2018-10-05T17:35:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0be868119925a8c6daf26a6812b814966625b4a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/samtools/htsjdk/pulls/1188/commits","review_comments_url":"https://api.github.com/repos/samtools/htsjdk/pulls/1188/comments","review_comment_url":"https://api.github.com/repos/samtools/htsjdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/samtools/htsjdk/issues/1188/comments","statuses_url":"https://api.github.com/repos/samtools/htsjdk/statuses/6d40e0a8b458edcd2dc7a2fa58d6f4dbc61f7310","head":{"label":"samtools:nh_binary_codec_empty_string","ref":"nh_binary_codec_empty_string","sha":"6d40e0a8b458edcd2dc7a2fa58d6f4dbc61f7310","user":{"login":"samtools","id":1518450,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTg0NTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1518450?v=4","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"repo":{"id":19272315,"node_id":"MDEwOlJlcG9zaXRvcnkxOTI3MjMxNQ==","name":"htsjdk","full_name":"samtools/htsjdk","private":false,"owner":{"login":"samtools","id":1518450,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTg0NTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1518450?v=4","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/samtools/htsjdk","description":"A Java API for high-throughput sequencing data (HTS) formats.","fork":false,"url":"https://api.github.com/repos/samtools/htsjdk","forks_url":"https://api.github.com/repos/samtools/htsjdk/forks","keys_url":"https://api.github.com/repos/samtools/htsjdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samtools/htsjdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samtools/htsjdk/teams","hooks_url":"https://api.github.com/repos/samtools/htsjdk/hooks","issue_events_url":"https://api.github.com/repos/samtools/htsjdk/issues/events{/number}","events_url":"https://api.github.com/repos/samtools/htsjdk/events","assignees_url":"https://api.github.com/repos/samtools/htsjdk/assignees{/user}","branches_url":"https://api.github.com/repos/samtools/htsjdk/branches{/branch}","tags_url":"https://api.github.com/repos/samtools/htsjdk/tags","blobs_url":"https://api.github.com/repos/samtools/htsjdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samtools/htsjdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samtools/htsjdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/samtools/htsjdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samtools/htsjdk/statuses/{sha}","languages_url":"https://api.github.com/repos/samtools/htsjdk/languages","stargazers_url":"https://api.github.com/repos/samtools/htsjdk/stargazers","contributors_url":"https://api.github.com/repos/samtools/htsjdk/contributors","subscribers_url":"https://api.github.com/repos/samtools/htsjdk/subscribers","subscription_url":"https://api.github.com/repos/samtools/htsjdk/subscription","commits_url":"https://api.github.com/repos/samtools/htsjdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/samtools/htsjdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/samtools/htsjdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/samtools/htsjdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/samtools/htsjdk/contents/{+path}","compare_url":"https://api.github.com/repos/samtools/htsjdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samtools/htsjdk/merges","archive_url":"https://api.github.com/repos/samtools/htsjdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samtools/htsjdk/downloads","issues_url":"https://api.github.com/repos/samtools/htsjdk/issues{/number}","pulls_url":"https://api.github.com/repos/samtools/htsjdk/pulls{/number}","milestones_url":"https://api.github.com/repos/samtools/htsjdk/milestones{/number}","notifications_url":"https://api.github.com/repos/samtools/htsjdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samtools/htsjdk/labels{/name}","releases_url":"https://api.github.com/repos/samtools/htsjdk/releases{/id}","deployments_url":"https://api.github.com/repos/samtools/htsjdk/deployments","created_at":"2014-04-29T10:11:28Z","updated_at":"2018-10-05T16:45:22Z","pushed_at":"2018-10-05T17:19:24Z","git_url":"git://github.com/samtools/htsjdk.git","ssh_url":"git@github.com:samtools/htsjdk.git","clone_url":"https://github.com/samtools/htsjdk.git","svn_url":"https://github.com/samtools/htsjdk","homepage":"http://samtools.github.io/htsjdk/","size":67893,"stargazers_count":170,"watchers_count":170,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":189,"mirror_url":null,"archived":false,"open_issues_count":238,"license":null,"forks":189,"open_issues":238,"watchers":170,"default_branch":"master"}},"base":{"label":"samtools:master","ref":"master","sha":"a7214cac11d7e8dadbe4d5b7dd1e208661e3592e","user":{"login":"samtools","id":1518450,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTg0NTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1518450?v=4","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"repo":{"id":19272315,"node_id":"MDEwOlJlcG9zaXRvcnkxOTI3MjMxNQ==","name":"htsjdk","full_name":"samtools/htsjdk","private":false,"owner":{"login":"samtools","id":1518450,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MTg0NTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1518450?v=4","gravatar_id":"","url":"https://api.github.com/users/samtools","html_url":"https://github.com/samtools","followers_url":"https://api.github.com/users/samtools/followers","following_url":"https://api.github.com/users/samtools/following{/other_user}","gists_url":"https://api.github.com/users/samtools/gists{/gist_id}","starred_url":"https://api.github.com/users/samtools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samtools/subscriptions","organizations_url":"https://api.github.com/users/samtools/orgs","repos_url":"https://api.github.com/users/samtools/repos","events_url":"https://api.github.com/users/samtools/events{/privacy}","received_events_url":"https://api.github.com/users/samtools/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/samtools/htsjdk","description":"A Java API for high-throughput sequencing data (HTS) formats.","fork":false,"url":"https://api.github.com/repos/samtools/htsjdk","forks_url":"https://api.github.com/repos/samtools/htsjdk/forks","keys_url":"https://api.github.com/repos/samtools/htsjdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samtools/htsjdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samtools/htsjdk/teams","hooks_url":"https://api.github.com/repos/samtools/htsjdk/hooks","issue_events_url":"https://api.github.com/repos/samtools/htsjdk/issues/events{/number}","events_url":"https://api.github.com/repos/samtools/htsjdk/events","assignees_url":"https://api.github.com/repos/samtools/htsjdk/assignees{/user}","branches_url":"https://api.github.com/repos/samtools/htsjdk/branches{/branch}","tags_url":"https://api.github.com/repos/samtools/htsjdk/tags","blobs_url":"https://api.github.com/repos/samtools/htsjdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samtools/htsjdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samtools/htsjdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/samtools/htsjdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samtools/htsjdk/statuses/{sha}","languages_url":"https://api.github.com/repos/samtools/htsjdk/languages","stargazers_url":"https://api.github.com/repos/samtools/htsjdk/stargazers","contributors_url":"https://api.github.com/repos/samtools/htsjdk/contributors","subscribers_url":"https://api.github.com/repos/samtools/htsjdk/subscribers","subscription_url":"https://api.github.com/repos/samtools/htsjdk/subscription","commits_url":"https://api.github.com/repos/samtools/htsjdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/samtools/htsjdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/samtools/htsjdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/samtools/htsjdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/samtools/htsjdk/contents/{+path}","compare_url":"https://api.github.com/repos/samtools/htsjdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samtools/htsjdk/merges","archive_url":"https://api.github.com/repos/samtools/htsjdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samtools/htsjdk/downloads","issues_url":"https://api.github.com/repos/samtools/htsjdk/issues{/number}","pulls_url":"https://api.github.com/repos/samtools/htsjdk/pulls{/number}","milestones_url":"https://api.github.com/repos/samtools/htsjdk/milestones{/number}","notifications_url":"https://api.github.com/repos/samtools/htsjdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samtools/htsjdk/labels{/name}","releases_url":"https://api.github.com/repos/samtools/htsjdk/releases{/id}","deployments_url":"https://api.github.com/repos/samtools/htsjdk/deployments","created_at":"2014-04-29T10:11:28Z","updated_at":"2018-10-05T16:45:22Z","pushed_at":"2018-10-05T17:19:24Z","git_url":"git://github.com/samtools/htsjdk.git","ssh_url":"git@github.com:samtools/htsjdk.git","clone_url":"https://github.com/samtools/htsjdk.git","svn_url":"https://github.com/samtools/htsjdk","homepage":"http://samtools.github.io/htsjdk/","size":67893,"stargazers_count":170,"watchers_count":170,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":189,"mirror_url":null,"archived":false,"open_issues_count":238,"license":null,"forks":189,"open_issues":238,"watchers":170,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/1188"},"html":{"href":"https://github.com/samtools/htsjdk/pull/1188"},"issue":{"href":"https://api.github.com/repos/samtools/htsjdk/issues/1188"},"comments":{"href":"https://api.github.com/repos/samtools/htsjdk/issues/1188/comments"},"review_comments":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/1188/comments"},"review_comment":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/samtools/htsjdk/pulls/1188/commits"},"statuses":{"href":"https://api.github.com/repos/samtools/htsjdk/statuses/6d40e0a8b458edcd2dc7a2fa58d6f4dbc61f7310"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"pshapiro4broad"}}