Skip to content
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

Merged
merged 2 commits into from
Sep 26, 2018
Merged

fixing bug in SeekableHttpStream.read #1182

merged 2 commits into from
Sep 26, 2018

Conversation

lbergelson
Copy link
Member

* 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
@lbergelson
Copy link
Member Author

@dtitov I think this should fix the problem you reported.

@dtitov
Copy link

dtitov commented Sep 26, 2018

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary import?

Copy link
Member Author

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))){
Copy link
Contributor

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))) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@codecov-io
Copy link

codecov-io commented Sep 26, 2018

Codecov Report

Merging #1182 into master will increase coverage by 0.008%.
The diff coverage is 66.667%.

@@               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
Impacted Files Coverage Δ Complexity Δ
...dk/samtools/seekablestream/SeekableHTTPStream.java 57.353% <66.667%> (-0.223%) 13 <0> (ø)
...sjdk/samtools/util/Md5CalculatingOutputStream.java 74.359% <0%> (+7.692%) 8% <0%> (+1%) ⬆️

@lbergelson lbergelson merged commit 49c70e5 into master Sep 26, 2018
@lbergelson lbergelson deleted the lb_fix_http_bug branch September 26, 2018 14:39
@@ -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))){
Copy link
Contributor

@pshapiro4broad pshapiro4broad Sep 26, 2018

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.

Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Indefinite loop caused by condition in SeekableHTTPStream
5 participants