-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixing bug in SeekableHttpStream.read #1182
Conversation
* a bug in SeekableHttpStream could cause clients to go into an infinite loop because read would return 0 when trying to read one byte past the end of the file * fixes #1181
@dtitov I think this should fix the problem you reported. |
Thanks for the quick fix! I tested it and it works 👍 |
@@ -31,6 +31,7 @@ | |||
import java.io.File; | |||
import java.io.FileNotFoundException; | |||
import java.io.IOException; | |||
import java.net.MalformedURLException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -69,6 +70,20 @@ public void testRandomRead() throws IOException { | |||
assertEquals(buffer1, buffer2); | |||
} | |||
|
|||
@Test | |||
public void testReadExactlyOneByteAtEndOfFile() throws IOException { | |||
try( SeekableStream stream = new SeekableHTTPStream(new URL(BAM_URL_STRING))){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd whitespace here, I would expect to see try (SeekableStream stream = new SeekableHTTPStream(new URL(BAM_URL_STRING))) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Codecov Report
@@ Coverage Diff @@
## master #1182 +/- ##
===============================================
+ Coverage 68.398% 68.406% +0.008%
- Complexity 8013 8014 +1
===============================================
Files 541 541
Lines 32688 32690 +2
Branches 5528 5529 +1
===============================================
+ Hits 22358 22362 +4
+ Misses 8125 8124 -1
+ Partials 2205 2204 -1
|
@@ -69,6 +69,20 @@ public void testRandomRead() throws IOException { | |||
assertEquals(buffer1, buffer2); | |||
} | |||
|
|||
@Test | |||
public void testReadExactlyOneByteAtEndOfFile() throws IOException { | |||
try (final SeekableStream stream = new SeekableHTTPStream(new URL(BAM_URL_STRING))){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost, still missing the space between the ){
. If you select the line and use the IDE's Reformat Code it will fix it for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, didn't see your comment until after I merged
SeekableHttpStream
could cause clients to go into an infinite loop because read would return 0 when trying to read one byte past the end of the file